TimeZone 클래스

정의

주의

System.TimeZone has been deprecated. Please investigate the use of System.TimeZoneInfo instead.

주의

System.TimeZone has been deprecated. Investigate the use of System.TimeZoneInfo instead.

표준 시간대를 나타냅니다.

public ref class TimeZone abstract
[System.Obsolete("System.TimeZone has been deprecated.  Please investigate the use of System.TimeZoneInfo instead.")]
public abstract class TimeZone
[System.Obsolete("System.TimeZone has been deprecated. Investigate the use of System.TimeZoneInfo instead.")]
public abstract class TimeZone
[System.Serializable]
public abstract class TimeZone
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class TimeZone
[<System.Obsolete("System.TimeZone has been deprecated.  Please investigate the use of System.TimeZoneInfo instead.")>]
type TimeZone = class
[<System.Obsolete("System.TimeZone has been deprecated. Investigate the use of System.TimeZoneInfo instead.")>]
type TimeZone = class
[<System.Serializable>]
type TimeZone = class
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type TimeZone = class
Public MustInherit Class TimeZone
상속
TimeZone
특성

예제

다음 예제에서는 선택한 TimeZone 클래스 요소를 참조하고 표시합니다.

// Example of selected TimeZone class elements.
using namespace System;
using namespace System::Globalization;
int main()
{
   String^ dataFmt = "{0,-30}{1}";
   String^ timeFmt = "{0,-30}{1:yyyy-MM-dd HH:mm}";
   Console::WriteLine( "This example of selected TimeZone class "
   "elements generates the following \n"
   "output, which varies depending on the "
   "time zone in which it is run.\n" );
   
   // Get the local time zone and the current local time and year.
   TimeZone^ localZone = TimeZone::CurrentTimeZone;
   DateTime currentDate = DateTime::Now;
   int currentYear = currentDate.Year;
   
   // Display the names for standard time and daylight saving 
   // time for the local time zone.
   Console::WriteLine( dataFmt, "Standard time name:", localZone->StandardName );
   Console::WriteLine( dataFmt, "Daylight saving time name:", localZone->DaylightName );
   
   // Display the current date and time and show if they occur 
   // in daylight saving time.
   Console::WriteLine( String::Concat( "\n", timeFmt ), "Current date and time:", currentDate );
   Console::WriteLine( dataFmt, "Daylight saving time?", localZone->IsDaylightSavingTime( currentDate ) );
   
   // Get the current Coordinated Universal Time (UTC) and UTC 
   // offset.
   DateTime currentUTC = localZone->ToUniversalTime( currentDate );
   TimeSpan currentOffset = localZone->GetUtcOffset( currentDate );
   Console::WriteLine( timeFmt, "Coordinated Universal Time:", currentUTC );
   Console::WriteLine( dataFmt, "UTC offset:", currentOffset );
   
   // Get the DaylightTime object for the current year.
   DaylightTime^ daylight = localZone->GetDaylightChanges( currentYear );
   
   // Display the daylight saving time range for the current year.
   Console::WriteLine( "\nDaylight saving time for year {0}:", currentYear );
   Console::WriteLine( "{0:yyyy-MM-dd HH:mm} to "
   "{1:yyyy-MM-dd HH:mm}, delta: {2}", daylight->Start, daylight->End, daylight->Delta );
}

/*
This example of selected TimeZone class elements generates the following
output, which varies depending on the time zone in which it is run.

Standard time name:           Pacific Standard Time
Daylight saving time name:    Pacific Daylight Time

Current date and time:        2006-01-06 16:47
Daylight saving time?         False
Coordinated Universal Time:   2006-01-07 00:47
UTC offset:                   -08:00:00

Daylight saving time for year 2006:
2006-04-02 02:00 to 2006-10-29 02:00, delta: 01:00:00
*/
// Example of selected TimeZone class elements.
using System;
using System.Globalization;

class TimeZoneDemo
{
    static void Main( )
    {
        const string dataFmt = "{0,-30}{1}";
        const string timeFmt = "{0,-30}{1:yyyy-MM-dd HH:mm}";

        Console.WriteLine(
            "This example of selected TimeZone class " +
            "elements generates the following \n" +
            "output, which varies depending on the " +
            "time zone in which it is run.\n" );

        // Get the local time zone and the current local time and year.
        TimeZone localZone = TimeZone.CurrentTimeZone;
        DateTime currentDate = DateTime.Now;
        int      currentYear = currentDate.Year;

        // Display the names for standard time and daylight saving 
        // time for the local time zone.
        Console.WriteLine( dataFmt, "Standard time name:", 
            localZone.StandardName );
        Console.WriteLine( dataFmt, "Daylight saving time name:", 
            localZone.DaylightName );

        // Display the current date and time and show if they occur 
        // in daylight saving time.
        Console.WriteLine( "\n" + timeFmt, "Current date and time:",
            currentDate );
        Console.WriteLine( dataFmt, "Daylight saving time?", 
            localZone.IsDaylightSavingTime( currentDate ) );

        // Get the current Coordinated Universal Time (UTC) and UTC 
        // offset.
        DateTime currentUTC = 
            localZone.ToUniversalTime( currentDate );
        TimeSpan currentOffset = 
            localZone.GetUtcOffset( currentDate );

        Console.WriteLine( timeFmt, "Coordinated Universal Time:", 
            currentUTC );
        Console.WriteLine( dataFmt, "UTC offset:", currentOffset );

        // Get the DaylightTime object for the current year.
        DaylightTime daylight = 
            localZone.GetDaylightChanges( currentYear );

        // Display the daylight saving time range for the current year.
        Console.WriteLine( 
            "\nDaylight saving time for year {0}:", currentYear );
        Console.WriteLine( "{0:yyyy-MM-dd HH:mm} to " +
            "{1:yyyy-MM-dd HH:mm}, delta: {2}", 
            daylight.Start, daylight.End, daylight.Delta );
    } 
} 

/*
This example of selected TimeZone class elements generates the following
output, which varies depending on the time zone in which it is run.

Standard time name:           Pacific Standard Time
Daylight saving time name:    Pacific Daylight Time

Current date and time:        2006-01-06 16:47
Daylight saving time?         False
Coordinated Universal Time:   2006-01-07 00:47
UTC offset:                   -08:00:00

Daylight saving time for year 2006:
2006-04-02 02:00 to 2006-10-29 02:00, delta: 01:00:00
*/
' Example of selected TimeZone class elements.
Imports System.Globalization

Module TimeZoneDemo

    Sub Main( )

        Const dataFmt As String = "{0,-30}{1}"
        Const timeFmt As String = "{0,-30}{1:yyyy-MM-dd HH:mm}"

        Console.WriteLine( "This example of selected " & _
            "TimeZone class elements generates the following " & _
            vbCrLf & "output, which varies depending on the " & _
            "time zone in which it is run." & vbCrLf )

        ' Get the local time zone and the current local time and year.
        Dim localZone As TimeZone = TimeZone.CurrentTimeZone
        Dim currentDate As DateTime = DateTime.Now
        Dim currentYear As Integer = currentDate.Year

        ' Display the names for standard time and daylight saving 
        ' time for the local time zone.
        Console.WriteLine( dataFmt, "Standard time name:", _
            localZone.StandardName )
        Console.WriteLine( dataFmt, "Daylight saving time name:", _
            localZone.DaylightName )

        ' Display the current date and time and show if they occur 
        ' in daylight saving time.
        Console.WriteLine( vbCrLf & timeFmt, _
            "Current date and time:", currentDate )
        Console.WriteLine( dataFmt, "Daylight saving time?", _
            localZone.IsDaylightSavingTime( currentDate ) )

        ' Get the current Coordinated Universal Time (UTC) and UTC 
        ' offset.
        Dim currentUTC As DateTime = _
            localZone.ToUniversalTime( currentDate )
        Dim currentOffset As TimeSpan = _
            localZone.GetUtcOffset( currentDate )

        Console.WriteLine( timeFmt, "Coordinated Universal Time:", _
            currentUTC )
        Console.WriteLine( dataFmt, "UTC offset:", currentOffset )

        ' Get the DaylightTime object for the current year.
        Dim daylight As DaylightTime = _
            localZone.GetDaylightChanges( currentYear )

        ' Display the daylight saving time range for the current year.
        Console.WriteLine( vbCrLf & _
            "Daylight saving time for year {0}:", currentYear )
        Console.WriteLine( "{0:yyyy-MM-dd HH:mm} to " & _
            "{1:yyyy-MM-dd HH:mm}, delta: {2}", _
            daylight.Start, daylight.End, daylight.Delta )
    End Sub 
End Module 

'This example of selected TimeZone class elements generates the following
'output, which varies depending on the time zone in which it is run.
'
'Standard time name:           Pacific Standard Time
'Daylight saving time name:    Pacific Daylight Time
'
'Current date and time:        2006-01-06 16:47
'Daylight saving time?         False
'Coordinated Universal Time:   2006-01-07 00:47
'UTC offset:                   -08:00:00
'
'Daylight saving time for year 2006:
'2006-04-02 02:00 to 2006-10-29 02:00, delta: 01:00:00

설명

표준 시간대는 동일한 표준 시간이 사용되는 지리적 지역입니다.

중요

가능하면 클래스 대신 클래스를 TimeZone 사용합니다TimeZoneInfo.

클래스를 TimeZone 사용하여 현재 표준 시간대에 대한 정보를 검색하고 현지 시간에서 UTC(협정 세계시)로 또는 그 반대로 시간을 변환할 수 있습니다. 그러나 클래스를 TimeZone 사용하여 지역 영역 이외의 표준 시간대를 나타내거나 한 표준 시간대에서 다른 표준 시간대로의 날짜 및 시간 변환을 처리할 수 없습니다. 이를 위해 클래스를 TimeZoneInfo 사용합니다. 이 클래스를 사용하여 로컬 시스템에 정의된 표준 시간대에 대한 정보를 검색하고, 사용자 지정 표준 시간대를 만들고, 시간을 한 표준 시간대에서 다른 표준 시간대로 변환할 수 있습니다.

이 클래스는 TimeZone 현지 표준 시간대에 대한 일광 절약 시간 조정 규칙 하나만 지원합니다. 따라서 클래스는 TimeZone 일광 절약 시간 정보를 정확하게 보고하거나 최신 조정 규칙이 적용되는 기간 동안에만 UTC와 현지 시간 간을 변환할 수 있습니다. 반면, 클래스는 TimeZoneInfo 여러 조정 규칙을 지원하므로 기록 표준 시간대 데이터를 사용할 수 있습니다.

구현자 참고

Visual Basic 표시된 MustOverride 멤버에 대한 abstract 구현을 제공하는 것 외에도 파생된 TimeZone 클래스가 메서드의 기본 동작을 재정의 ToLocalTime(DateTime) 하는 것이 중요합니다. 이는 .NET Framework 버전 2.0의 ToLocalTime(DateTime) 기본 동작이 .NET Framework 버전 1.0 및 1.1에서와 마찬가지로 호출GetUtcOffset(DateTime)에 의존하지 않기 때문입니다. 자세한 내용은 메서드를 참조하세요 ToLocalTime(DateTime) .

생성자

TimeZone()

TimeZone 클래스의 새 인스턴스를 초기화합니다.

속성

CurrentTimeZone

현재 컴퓨터의 표준 시간대를 가져옵니다.

DaylightName

일광 절약 표준 시간대 이름을 가져옵니다.

StandardName

표준 시간대 이름을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetDaylightChanges(Int32)

특정 연도에 대한 일광 절약 시간 적용 기간을 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
GetUtcOffset(DateTime)

지정된 현지 시간에 대한 UTC(협정 세계시) 오프셋을 반환합니다.

IsDaylightSavingTime(DateTime)

지정된 날짜와 시간이 일광 절약 시간 적용 기간 내에 있는지의 여부를 나타내는 값을 반환합니다.

IsDaylightSavingTime(DateTime, DaylightTime)

지정된 날짜와 시간이 지정된 일광 절약 시간 적용 기간 내에 있는지의 여부를 나타내는 값을 반환합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToLocalTime(DateTime)

지정된 날짜 및 시간 값에 해당하는 현지 시간을 반환합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
ToUniversalTime(DateTime)

지정된 시간에 해당하는 UTC(협정 세계시)를 반환합니다.

적용 대상

추가 정보