DateTimeOffset 생성자

정의

DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

오버로드

DateTimeOffset(DateTime)

지정된 DateTime 값을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

DateTimeOffset(DateTime, TimeSpan)

지정된 DateTime 값과 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

DateTimeOffset(Int64, TimeSpan)

지정된 수의 틱과 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

DateTimeOffset(DateOnly, TimeOnly, TimeSpan)

지정된 , 및 를 사용하여 구조체의 DateTimeOffset 새 instance 초기화합니다offset. timedate

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

지정된 연도, 월, 일, 시, 분, 초 및 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

지정된 연도, 월, 일, 시, 분, 초, 밀리초 및 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan)

지정된 달력의 지정된 연도, 월, 일, 시, 분, 초, 밀리초 및 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

지정된 year, minutesecondmicrosecondmonthdayhourmillisecond및 를 사용하여 구조체의 DateTimeOffset 새 instance 초기화합니다.offset

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan)

지정된 year, minutesecondmicrosecondmonthdayhourmillisecond및 를 사용하여 구조체의 DateTimeOffset 새 instance 초기화합니다.offset

DateTimeOffset(DateTime)

지정된 DateTime 값을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

public:
 DateTimeOffset(DateTime dateTime);
public DateTimeOffset (DateTime dateTime);
new DateTimeOffset : DateTime -> DateTimeOffset
Public Sub New (dateTime As DateTime)

매개 변수

dateTime
DateTime

날짜와 시간입니다.

예외

오프셋을 적용한 결과 UTC(협정 세계시) 날짜 및 시간이 DateTimeOffset.MinValue보다 낮습니다.

또는

오프셋을 적용한 결과 UTC 날짜 및 시간은 DateTimeOffset.MaxValue보다 낮습니다.

예제

다음 예제에서는 매개 변수의 DateTime.Kind 속성 dateTime 값이 이 생성자가 반환하는 날짜 및 시간 값에 미치는 영향을 보여 줍니다.

DateTime localNow = DateTime.Now;
DateTimeOffset localOffset = new DateTimeOffset(localNow);
Console.WriteLine(localOffset.ToString());

DateTime utcNow = DateTime.UtcNow;
DateTimeOffset utcOffset = new DateTimeOffset(utcNow);
Console.WriteLine(utcOffset.ToString());

DateTime unspecifiedNow = DateTime.SpecifyKind(DateTime.Now,
                               DateTimeKind.Unspecified);
DateTimeOffset unspecifiedOffset = new DateTimeOffset(unspecifiedNow);
Console.WriteLine(unspecifiedOffset.ToString());
//
// The code produces the following output if run on Feb. 23, 2007, on
// a system 8 hours earlier than UTC:
//   2/23/2007 4:21:58 PM -08:00
//   2/24/2007 12:21:58 AM +00:00
//   2/23/2007 4:21:58 PM -08:00
let localNow = DateTime.Now
let localOffset = DateTimeOffset localNow
printfn $"{localOffset}"

let utcNow = DateTime.UtcNow
let utcOffset = DateTimeOffset utcNow
printfn "{utcOffset}"

let unspecifiedNow = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified)
let unspecifiedOffset = DateTimeOffset unspecifiedNow
printfn $"{unspecifiedOffset}"

// The code produces the following output if run on Feb. 23, 2007, on
// a system 8 hours earlier than UTC:
//   2/23/2007 4:21:58 PM -08:00
//   2/24/2007 12:21:58 AM +00:00
//   2/23/2007 4:21:58 PM -08:00
Dim localNow As Date = Date.Now
Dim localOffset As New DateTimeOffset(localNow)
Console.WriteLine(localOffset.ToString())

Dim utcNow As Date = Date.UtcNow
Dim utcOffset As New DateTimeOffset(utcNow)
Console.WriteLine(utcOffset.ToString())

Dim unspecifiedNow As Date = Date.SpecifyKind(Date.Now, _
                                  DateTimeKind.Unspecified)
Dim unspecifiedOffset As New DateTimeOffset(unspecifiedNow)
Console.WriteLine(unspecifiedOffset.ToString())
'
' The code produces the following output if run on Feb. 23, 2007, on
' a system 8 hours earlier than UTC:
'    2/23/2007 4:21:58 PM -08:00
'    2/24/2007 12:21:58 AM +00:00
'    2/23/2007 4:21:58 PM -08:00

설명

이 생성자의 동작은 매개 변수의 DateTime.Kind 속성 값에 dateTime 따라 달라집니다.

추가 정보

적용 대상

DateTimeOffset(DateTime, TimeSpan)

지정된 DateTime 값과 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

public:
 DateTimeOffset(DateTime dateTime, TimeSpan offset);
public DateTimeOffset (DateTime dateTime, TimeSpan offset);
new DateTimeOffset : DateTime * TimeSpan -> DateTimeOffset
Public Sub New (dateTime As DateTime, offset As TimeSpan)

매개 변수

dateTime
DateTime

날짜와 시간입니다.

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

예외

dateTime.KindUtc와 같고 offset은 0과 같지 않습니다.

또는

dateTime.KindLocal과 같고 offset은 시스템의 현지 표준 시간대 오프셋과 같지 않습니다.

또는

offset이 전체 분 내에서 지정되지 않았습니다.

offset이 -14시간보다 작거나 14시간보다 큽니다.

또는

UtcDateTime이 DateTimeOffset.MinValue보다 작거나 DateTimeOffset.MaxValue보다 큽니다.

예제

다음 예제에서는 날짜 및 시간으로 개체를 DateTimeOffset 초기화하는 방법과 해당 표준 시간대를 미리 알 수 없는 경우 현지 표준 시간대의 오프셋을 보여 줍니다.

DateTime localTime = new DateTime(2007, 07, 12, 06, 32, 00);
DateTimeOffset dateAndOffset = new DateTimeOffset(localTime,
                         TimeZoneInfo.Local.GetUtcOffset(localTime));
Console.WriteLine(dateAndOffset);
// The code produces the following output:
//    7/12/2007 6:32:00 AM -07:00
let localTime = DateTime(2007, 07, 12, 06, 32, 00)
let dateAndOffset = DateTimeOffset(localTime, TimeZoneInfo.Local.GetUtcOffset localTime)
printfn $"{dateAndOffset}"
// The code produces the following output:
//    7/12/2007 6:32:00 AM -07:00
Dim localTime As Date = #07/12/2007 6:32AM#
Dim dateAndOffset As New DateTimeOffset(localTime, _
                         TimeZoneInfo.Local.GetUtcOffset(localTime))
Console.WriteLine(dateAndOffset)
' The code produces the following output:
'    7/12/2007 6:32:00 AM -07:00

설명

이 생성자의 동작은 부분적으로 매개 변수의 Kind 속성 값에 dateTime 따라 달라집니다.

추가 정보

적용 대상

DateTimeOffset(Int64, TimeSpan)

지정된 수의 틱과 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

public:
 DateTimeOffset(long ticks, TimeSpan offset);
public DateTimeOffset (long ticks, TimeSpan offset);
new DateTimeOffset : int64 * TimeSpan -> DateTimeOffset
Public Sub New (ticks As Long, offset As TimeSpan)

매개 변수

ticks
Int64

0001년 1월 1일 자정 12시 00분 00초부터 경과한 100나노초 간격의 수로 표현한 날짜와 시간입니다.

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

예외

offset이 전체 분 내에서 지정되지 않았습니다.

속성이 UtcDateTimeDateTimeOffset.MinValue 보다 이전이거나 DateTimeOffset.MaxValue보다 낮습니다.

또는

ticks이(가) DateTimeOffset.MinValue.Ticks보다 작거나 DateTimeOffset.MaxValue.Ticks보다 큽니다.

또는

Offset이 -14시간보다 작거나 14시간보다 큽니다.

예제

다음 예제에서는 오프셋이 -5인 임의의 날짜(이 경우 2007년 7월 16일 오후 1시 32분)의 틱 수를 사용하여 개체를 초기화 DateTimeOffset 합니다.

DateTime dateWithoutOffset = new DateTime(2007, 7, 16, 13, 32, 00);
DateTimeOffset timeFromTicks = new DateTimeOffset(dateWithoutOffset.Ticks,
                               new TimeSpan(-5, 0, 0));
Console.WriteLine(timeFromTicks.ToString());
// The code produces the following output:
//    7/16/2007 1:32:00 PM -05:00
let dateWithoutOffset = DateTime(2007, 7, 16, 13, 32, 00)
let timeFromTicks = DateTimeOffset(dateWithoutOffset.Ticks, TimeSpan(-5, 0, 0))
printfn $"{timeFromTicks}"
// The code produces the following output:
//    7/16/2007 1:32:00 PM -05:00
Dim dateWithoutOffset As Date = #07/16/2007 1:32PM#
Dim timeFromTicks As New DateTimeOffset(datewithoutOffset.Ticks, _
                         New TimeSpan(-5, 0, 0))
Console.WriteLine(timeFromTicks.ToString())
' The code produces the following output:
'    7/16/2007 1:32:00 PM -05:00

설명

일반적으로 로컬 시간으로 값을 인스턴스화 DateTimeOffset 하기 위해 생성자를 호출 DateTimeOffset 하려고 하면 로컬 표준 시간대 이외의 오프셋이 을 ArgumentExceptionthrow합니다. 이 생성자의 오버로드를 DateTimeOffset 사용하여 이 제한 사항을 해결할 수 있습니다. 다음 예제에서는 현지 시간의 틱 수를 사용하여 오프셋이 반드시 현지 시간을 나타내는 것은 아닌 값을 인스턴스화 DateTimeOffset 합니다.

DateTime localTime = DateTime.Now;
DateTimeOffset nonLocalDateWithOffset = new DateTimeOffset(localTime.Ticks,
                                  new TimeSpan(2, 0, 0));
Console.WriteLine(nonLocalDateWithOffset);
//
// The code produces the following output if run on Feb. 23, 2007:
//    2/23/2007 4:37:50 PM +02:00
let localTime = DateTime.Now
let nonLocalDateWithOffset = DateTimeOffset(localTime.Ticks, TimeSpan(2, 0, 0))
printfn $"{nonLocalDateWithOffset}"
// The code produces the following output if run on Feb. 23, 2007:
//    2/23/2007 4:37:50 PM +02:00
Dim localTime As Date = Date.Now
Dim nonLocalDateWithOffset As New DateTimeOffset(localTime.Ticks, _
                                  New TimeSpan(2, 0, 0))
Console.WriteLine(nonLocalDateWithOffset)                                        
'
' The code produces the following output if run on Feb. 23, 2007:
'    2/23/2007 4:37:50 PM +02:00

추가 정보

적용 대상

DateTimeOffset(DateOnly, TimeOnly, TimeSpan)

지정된 , 및 를 사용하여 구조체의 DateTimeOffset 새 instance 초기화합니다offset. timedate

public:
 DateTimeOffset(DateOnly date, TimeOnly time, TimeSpan offset);
public DateTimeOffset (DateOnly date, TimeOnly time, TimeSpan offset);
new DateTimeOffset : DateOnly * TimeOnly * TimeSpan -> DateTimeOffset
Public Sub New (date As DateOnly, time As TimeOnly, offset As TimeSpan)

매개 변수

date
DateOnly

날짜 부분입니다.

time
TimeOnly

시간 파트입니다.

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

적용 대상

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

지정된 연도, 월, 일, 시, 분, 초 및 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

public:
 DateTimeOffset(int year, int month, int day, int hour, int minute, int second, TimeSpan offset);
public DateTimeOffset (int year, int month, int day, int hour, int minute, int second, TimeSpan offset);
new DateTimeOffset : int * int * int * int * int * int * TimeSpan -> DateTimeOffset
Public Sub New (year As Integer, month As Integer, day As Integer, hour As Integer, minute As Integer, second As Integer, offset As TimeSpan)

매개 변수

year
Int32

연도(1부터 9999까지)

month
Int32

월(1부터 12까지)

day
Int32

일(1부터 month에 있는 일수까지)

hour
Int32

시(0부터 23까지)

minute
Int32

분(0부터 59까지)

second
Int32

초(0부터 59까지)

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

예외

offset이 전체 시간(분)을 표시하지 않습니다.

year가 1보다 작거나 9999보다 큽니다.

또는

month가 1보다 작거나 12보다 큽니다.

또는

day가 1보다 작거나 month의 일 수보다 큽니다.

또는

hour가 0보다 작거나 23보다 큽니다.

또는

minute가 0보다 작거나 59보다 큽니다.

또는

second가 0보다 작거나 59보다 큽니다.

또는

offset이 -14시간보다 작거나 14시간보다 큽니다.

또는

속성이 UtcDateTimeDateTimeOffset.MinValue 보다 이전이거나 DateTimeOffset.MaxValue보다 낮습니다.

예제

다음 예제에서는 생성자 오버로드를 DateTimeOffset 사용하여 개체를 DateTimeOffset.DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) 인스턴스화합니다.

   DateTime specificDate = new DateTime(2008, 5, 1, 06, 32, 00);
   DateTimeOffset offsetDate = new DateTimeOffset(specificDate.Year,
                                   specificDate.Month,
                                   specificDate.Day,
                                   specificDate.Hour,
                                   specificDate.Minute,
                                   specificDate.Second,
                                   new TimeSpan(-5, 0, 0));
   Console.WriteLine("Current time: {0}", offsetDate);
   Console.WriteLine("Corresponding UTC time: {0}", offsetDate.UtcDateTime);
// The code produces the following output:
//    Current time: 5/1/2008 6:32:00 AM -05:00
//    Corresponding UTC time: 5/1/2008 11:32:00 AM
let specificDate = DateTime(2008, 5, 1, 06, 32, 00)
let offsetDate = DateTimeOffset(specificDate.Year,
                                specificDate.Month,
                                specificDate.Day,
                                specificDate.Hour,
                                specificDate.Minute,
                                specificDate.Second,
                                TimeSpan(-5, 0, 0))
printfn $"Current time: {offsetDate}"
printfn $"Corresponding UTC time: {offsetDate.UtcDateTime}"
// The code produces the following output:
//    Current time: 5/1/2008 6:32:00 AM -05:00
//    Corresponding UTC time: 5/1/2008 11:32:00 AM
   Dim specificDate As Date = #5/1/2008 6:32AM#
   Dim offsetDate As New DateTimeOffset(specificDate.Year, _
                                        specificDate.Month, _
                                        specificDate.Day, _
                                        specificDate.Hour, _
                                        specificDate.Minute, _
                                        specificDate.Second, _
                                        New TimeSpan(-5, 0, 0))
   Console.WriteLine("Current time: {0}", offsetDate)
   Console.WriteLine("Corresponding UTC time: {0}", offsetDate.UtcDateTime)                                              
' The code produces the following output:
'    Current time: 5/1/2008 6:32:00 AM -05:00
'    Corresponding UTC time: 5/1/2008 11:32:00 AM

설명

이 생성자는 , monthdayyear그레고리오력의 1년, 월 및 일로 해석합니다. 다른 달력에서 DateTimeOffset 연도, 월 및 일을 사용하여 값을 인스턴스화하려면 생성자를 호출합니다 DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan) .

추가 정보

적용 대상

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

지정된 연도, 월, 일, 시, 분, 초, 밀리초 및 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

public:
 DateTimeOffset(int year, int month, int day, int hour, int minute, int second, int millisecond, TimeSpan offset);
public DateTimeOffset (int year, int month, int day, int hour, int minute, int second, int millisecond, TimeSpan offset);
new DateTimeOffset : int * int * int * int * int * int * int * TimeSpan -> DateTimeOffset
Public Sub New (year As Integer, month As Integer, day As Integer, hour As Integer, minute As Integer, second As Integer, millisecond As Integer, offset As TimeSpan)

매개 변수

year
Int32

연도(1부터 9999까지)

month
Int32

월(1부터 12까지)

day
Int32

일(1부터 month에 있는 일수까지)

hour
Int32

시(0부터 23까지)

minute
Int32

분(0부터 59까지)

second
Int32

초(0부터 59까지)

millisecond
Int32

밀리초(0부터 999까지)

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

예외

offset이 전체 시간(분)을 표시하지 않습니다.

year가 1보다 작거나 9999보다 큽니다.

또는

month가 1보다 작거나 12보다 큽니다.

또는

day가 1보다 작거나 month의 일 수보다 큽니다.

또는

hour가 0보다 작거나 23보다 큽니다.

또는

minute가 0보다 작거나 59보다 큽니다.

또는

second가 0보다 작거나 59보다 큽니다.

또는

millisecond가 0보다 작거나 999보다 큽니다.

또는

offset가 -14보다 작거나 14보다 큽니다.

또는

UtcDateTime 속성이 DateTimeOffset.MinValue보다 이전이거나 DateTimeOffset.MaxValue보다 낮습니다.

예제

다음 예제에서는 생성자 오버로드를 DateTimeOffset 사용하여 개체를 DateTimeOffset.DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan) 인스턴스화합니다.

string fmt = "dd MMM yyyy HH:mm:ss";
DateTime thisDate = new DateTime(2007, 06, 12, 19, 00, 14, 16);
DateTimeOffset offsetDate = new DateTimeOffset(thisDate.Year,
                                               thisDate.Month,
                                               thisDate.Day,
                                               thisDate.Hour,
                                               thisDate.Minute,
                                               thisDate.Second,
                                               thisDate.Millisecond,
                                               new TimeSpan(2, 0, 0));
Console.WriteLine("Current time: {0}:{1}", offsetDate.ToString(fmt), offsetDate.Millisecond);
// The code produces the following output:
//    Current time: 12 Jun 2007 19:00:14:16
let fmt = "dd MMM yyyy HH:mm:ss"
let thisDate = DateTime(2007, 06, 12, 19, 00, 14, 16)
let offsetDate = DateTimeOffset(thisDate.Year,
                                thisDate.Month,
                                thisDate.Day,
                                thisDate.Hour,
                                thisDate.Minute,
                                thisDate.Second,
                                thisDate.Millisecond,
                                TimeSpan(2, 0, 0))
printfn $"Current time: {offsetDate.ToString fmt}:{offsetDate.Millisecond}"
// The code produces the following output:
//    Current time: 12 Jun 2007 19:00:14:16
Dim fmt As String = "dd MMM yyyy HH:mm:ss"
Dim thisDate As DateTime = New Date(2007, 06, 12, 19, 00, 14, 16)
Dim offsetDate As New DateTimeOffset(thisDate.Year, _
                                     thisDate.Month, _
                                     thisDate.Day, _
                                     thisDate.Hour, _
                                     thisDate.Minute, _
                                     thisDate.Second, _
                                     thisDate.Millisecond, _ 
                                     New TimeSpan(2, 0, 0))  
Console.WriteLine("Current time: {0}:{1}", offsetDate.ToString(fmt), _ 
                                           offsetDate.Millisecond)
' The code produces the following output:
'    Current time: 12 Jun 2007 19:00:14:16

설명

이 생성자는 , monthday 를 그레고리오력의 1년, 월 및 일로 해석year합니다. 다른 달력에서 DateTimeOffset 연도, 월 및 일을 사용하여 값을 인스턴스화하려면 생성자를 호출 DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan) 합니다.

추가 정보

적용 대상

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan)

지정된 달력의 지정된 연도, 월, 일, 시, 분, 초, 밀리초 및 오프셋을 사용하여 DateTimeOffset 구조체의 새 인스턴스를 초기화합니다.

public:
 DateTimeOffset(int year, int month, int day, int hour, int minute, int second, int millisecond, System::Globalization::Calendar ^ calendar, TimeSpan offset);
public DateTimeOffset (int year, int month, int day, int hour, int minute, int second, int millisecond, System.Globalization.Calendar calendar, TimeSpan offset);
new DateTimeOffset : int * int * int * int * int * int * int * System.Globalization.Calendar * TimeSpan -> DateTimeOffset
Public Sub New (year As Integer, month As Integer, day As Integer, hour As Integer, minute As Integer, second As Integer, millisecond As Integer, calendar As Calendar, offset As TimeSpan)

매개 변수

year
Int32

연도

month
Int32

월(1부터 12까지)

day
Int32

일(1부터 month에 있는 일수까지)

hour
Int32

시(0부터 23까지)

minute
Int32

분(0부터 59까지)

second
Int32

초(0부터 59까지)

millisecond
Int32

밀리초(0부터 999까지)

calendar
Calendar

year, monthday를 해석하는 데 사용되는 달력입니다.

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

예외

offset이 전체 시간(분)을 표시하지 않습니다.

calendarnull이 될 수 없는 경우

yearcalendar 매개 변수의 MinSupportedDateTime.Year보다 작거나 MaxSupportedDateTime.Year보다 큽니다.

또는

monthcalendaryear에 있는 개월 수보다 작거나 큽니다.

또는

day가 1보다 작거나 month의 일 수보다 큽니다.

또는

hour가 0보다 작거나 23보다 큽니다.

또는

minute가 0보다 작거나 59보다 큽니다.

또는

second가 0보다 작거나 59보다 큽니다.

또는

millisecond가 0보다 작거나 999보다 큽니다.

또는

offset이 -14시간보다 작거나 14시간보다 큽니다.

또는

year, monthday 매개 변수를 날짜 및 시간 값으로 나타낼 수 없습니다.

또는

UtcDateTime 속성이 DateTimeOffset.MinValue보다 이전이거나 DateTimeOffset.MaxValue보다 낮습니다.

예제

다음 예제에서는 클래스와 클래스의 인스턴스를 HijriCalendar 모두 HebrewCalendar 사용하여 값을 인스턴스화합니다DateTimeOffset. 그런 다음 해당 달력과 그레고리오력을 사용하여 해당 날짜가 콘솔에 표시됩니다.

CultureInfo fmt;
int year;
Calendar cal;
DateTimeOffset dateInCal;

// Instantiate DateTimeOffset with Hebrew calendar
year = 5770;
cal = new HebrewCalendar();
fmt = new CultureInfo("he-IL");
fmt.DateTimeFormat.Calendar = cal;
dateInCal = new DateTimeOffset(year, 7, 12,
                               15, 30, 0, 0,
                               cal,
                               new TimeSpan(2, 0, 0));
// Display the date in the Hebrew calendar
Console.WriteLine("Date in Hebrew Calendar: {0:g}",
                   dateInCal.ToString(fmt));
// Display the date in the Gregorian calendar
Console.WriteLine("Date in Gregorian Calendar: {0:g}", dateInCal);
Console.WriteLine();

// Instantiate DateTimeOffset with Hijri calendar
year = 1431;
cal = new HijriCalendar();
fmt = new CultureInfo("ar-SA");
fmt.DateTimeFormat.Calendar = cal;
dateInCal = new DateTimeOffset(year, 7, 12,
                               15, 30, 0, 0,
                               cal,
                               new TimeSpan(2, 0, 0));
// Display the date in the Hijri calendar
Console.WriteLine("Date in Hijri Calendar: {0:g}",
                   dateInCal.ToString(fmt));
// Display the date in the Gregorian calendar
Console.WriteLine("Date in Gregorian Calendar: {0:g}", dateInCal);
Console.WriteLine();
// Instantiate DateTimeOffset with Hebrew calendar
let year = 5770
let cal = HebrewCalendar()
let fmt = CultureInfo "he-IL"
fmt.DateTimeFormat.Calendar <- cal
let dateInCal = DateTimeOffset(year, 7, 12,
                               15, 30, 0, 0,
                               cal,
                               TimeSpan(2, 0, 0))
// Display the date in the Hebrew calendar
printfn $"Date in Hebrew Calendar: {dateInCal.ToString fmt:g}"
// Display the date in the Gregorian calendar
printfn $"Date in Gregorian Calendar: {dateInCal:g}\n"

// Instantiate DateTimeOffset with Hijri calendar
let year = 1431
let cal = HijriCalendar()
let fmt = CultureInfo "ar-SA"
fmt.DateTimeFormat.Calendar <- cal
let dateInCal = DateTimeOffset(year, 7, 12,
                               15, 30, 0, 0,
                               cal,
                               TimeSpan(2, 0, 0))
// Display the date in the Hijri calendar
printfn $"Date in Hijri Calendar: {dateInCal.ToString fmt:g}"
// Display the date in the Gregorian calendar
printfn $"Date in Gregorian Calendar: {dateInCal:g}\n"
Dim fmt As CultureInfo
Dim year As Integer
Dim cal As Calendar
Dim dateInCal As DateTimeOffset

' Instantiate DateTimeOffset with Hebrew calendar
year = 5770
cal = New HebrewCalendar()
fmt = New CultureInfo("he-IL")
fmt.DateTimeFormat.Calendar = cal      
dateInCal = New DateTimeOffset(year, 7, 12, _
                               15, 30, 0, 0, _
                               cal, _
                               New TimeSpan(2, 0, 0))
' Display the date in the Hebrew calendar
Console.WriteLine("Date in Hebrew Calendar: {0:g}", _
                   dateInCal.ToString(fmt))
' Display the date in the Gregorian calendar                         
Console.WriteLine("Date in Gregorian Calendar: {0:g}", dateInCal)
Console.WriteLine()

' Instantiate DateTimeOffset with Hijri calendar
year = 1431
cal = New HijriCalendar()
fmt = New CultureInfo("ar-SA")
fmt.DateTimeFormat.Calendar = cal
dateInCal = New DateTimeOffset(year, 7, 12, _
                               15, 30, 0, 0, _
                               cal, _
                               New TimeSpan(2, 0, 0))
' Display the date in the Hijri calendar
Console.WriteLine("Date in Hijri Calendar: {0:g}", _
                   dateInCal.ToString(fmt))
' Display the date in the Gregorian calendar                         
Console.WriteLine("Date in Gregorian Calendar: {0:g}", dateInCal)
Console.WriteLine()

설명

, , month, dayhour, minute, secondmillisecond 매개 변수는 year모두 매개 변수로 지정된 달력에 표현된 calendar 값을 반영합니다. 이러한 값이 이 달력을 사용하여 표현할 수 없는 날짜와 시간을 형성하는 경우 예외가 throw됩니다.

중요

일본어 달력의 시대는 천황 통치 기간을 기준으로 하므로 변경되어야 합니다. 예를 들어 2019년 5월 1일은 JapaneseCalendarJapaneseLunisolarCalendar에서 레이와 시대의 시작을 나타냅니다. 이러한 시대 변경 내용은 해당 달력을 사용하는 모든 애플리케이션에 영향을 줍니다. 자세한 내용과 애플리케이션이 영향을 받는지 여부를 확인하려면 .NET에서 일본 달력의 새 시대 처리를 참조하세요. Windows 시스템에서 애플리케이션을 테스트하여 시대 변화에 대한 준비 상태를 확인하는 방법에 대한 자세한 내용은 일본 시대 변화에 맞게 애플리케이션 준비를 참조하세요. 여러 시대가 있는 달력을 지원하는 .NET의 기능과 여러 연대를 지원하는 달력으로 작업할 때 모범 사례는 연대 작업을 참조하세요.

추가 정보

적용 대상

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, TimeSpan)

지정된 year, minutesecondmicrosecondmonthdayhourmillisecond및 를 사용하여 구조체의 DateTimeOffset 새 instance 초기화합니다.offset

public:
 DateTimeOffset(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond, TimeSpan offset);
public DateTimeOffset (int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond, TimeSpan offset);
new DateTimeOffset : int * int * int * int * int * int * int * int * TimeSpan -> DateTimeOffset
Public Sub New (year As Integer, month As Integer, day As Integer, hour As Integer, minute As Integer, second As Integer, millisecond As Integer, microsecond As Integer, offset As TimeSpan)

매개 변수

year
Int32

연도(1부터 9999까지)

month
Int32

월(1부터 12까지)

day
Int32

일(1부터 month에 있는 일수까지)

hour
Int32

시(0부터 23까지)

minute
Int32

분(0부터 59까지)

second
Int32

초(0부터 59까지)

millisecond
Int32

밀리초(0부터 999까지)

microsecond
Int32

마이크로초(0~999)입니다.

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

예외

offset이 전체 시간(분)을 표시하지 않습니다.

year가 1보다 작거나 9999보다 큽니다.

또는

month가 1보다 작거나 12보다 큽니다.

또는

day 가 1보다 작거나 month의 일 수보다 큽니다.

또는

hour가 0보다 작거나 23보다 큽니다.

또는

minute가 0보다 작거나 59보다 큽니다.

또는

second가 0보다 작거나 59보다 큽니다.

또는

millisecond가 0보다 작거나 999보다 큽니다.

또는

microsecond가 0보다 작거나 999보다 큽니다.

설명

이 생성자는 및 monthdayyear그레고리오력의 1년, 월 및 일로 해석합니다. 다른 달력에서 DateTimeOffset 연도, 월 및 일을 사용하여 값을 인스턴스화하려면 생성자를 호출 DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan) 합니다.

적용 대상

DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan)

지정된 year, minutesecondmicrosecondmonthdayhourmillisecond및 를 사용하여 구조체의 DateTimeOffset 새 instance 초기화합니다.offset

public:
 DateTimeOffset(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond, System::Globalization::Calendar ^ calendar, TimeSpan offset);
public DateTimeOffset (int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond, System.Globalization.Calendar calendar, TimeSpan offset);
new DateTimeOffset : int * int * int * int * int * int * int * int * System.Globalization.Calendar * TimeSpan -> DateTimeOffset
Public Sub New (year As Integer, month As Integer, day As Integer, hour As Integer, minute As Integer, second As Integer, millisecond As Integer, microsecond As Integer, calendar As Calendar, offset As TimeSpan)

매개 변수

year
Int32

연도(1부터 9999까지)

month
Int32

월(1부터 12까지)

day
Int32

일(1부터 month에 있는 일수까지)

hour
Int32

시(0부터 23까지)

minute
Int32

분(0부터 59까지)

second
Int32

초(0부터 59까지)

millisecond
Int32

밀리초(0부터 999까지)

microsecond
Int32

마이크로초(0~999)입니다.

calendar
Calendar

year, monthday를 해석하는 데 사용되는 달력입니다.

offset
TimeSpan

UTC(협정 세계시)를 기준으로 해당 시간의 오프셋입니다.

예외

offset이 전체 시간(분)을 표시하지 않습니다.

yearcalendar에서 지원되는 범위에 없습니다.

또는

month가 1보다 작거나 calendar의 개월 수보다 큽니다.

또는

day 가 1보다 작거나 month의 일 수보다 큽니다.

또는

hour가 0보다 작거나 23보다 큽니다.

또는

minute가 0보다 작거나 59보다 큽니다.

또는

second가 0보다 작거나 59보다 큽니다.

또는

millisecond가 0보다 작거나 999보다 큽니다.

또는

microsecond가 0보다 작거나 999보다 큽니다.

또는

offset이 -14시간보다 작거나 14시간보다 큽니다.

또는

year, monthday 매개 변수를 날짜 및 시간 값으로 나타낼 수 없습니다.

또는

UtcDateTime 속성이 MinValue 이전이거나 MaxValue 이후입니다.

설명

이 생성자는 및 monthdayyear그레고리오력의 1년, 월 및 일로 해석합니다. 다른 달력에서 DateTimeOffset 연도, 월 및 일을 사용하여 값을 인스턴스화하려면 생성자를 호출 DateTimeOffset(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, TimeSpan) 합니다.

적용 대상