GregorianCalendar.MaxSupportedDateTime 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得受 GregorianCalendar 型別所支援的最晚日期和時間。
public:
virtual property DateTime MaxSupportedDateTime { DateTime get(); };
public override DateTime MaxSupportedDateTime { get; }
[System.Runtime.InteropServices.ComVisible(false)]
public override DateTime MaxSupportedDateTime { get; }
member this.MaxSupportedDateTime : DateTime
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.MaxSupportedDateTime : DateTime
Public Overrides ReadOnly Property MaxSupportedDateTime As DateTime
屬性值
類型所支援 GregorianCalendar 的最新日期和時間,也就是 9999 年 12 月 31 日 C.E. 的最後一個時間,相當於 DateTime.MaxValue。
- 屬性
範例
下列程式代碼範例會取得行事曆的最小值和最大值。
using namespace System;
using namespace System::Globalization;
int main()
{
// Create an instance of the calendar.
GregorianCalendar^ myCal = gcnew GregorianCalendar;
Console::WriteLine( myCal );
// Display the MinSupportedDateTime.
DateTime myMin = myCal->MinSupportedDateTime;
Console::WriteLine( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
// Display the MaxSupportedDateTime.
DateTime myMax = myCal->MaxSupportedDateTime;
Console::WriteLine( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
}
/*
This code produces the following output.
System.Globalization.GregorianCalendar
MinSupportedDateTime: 01/01/0001
MaxSupportedDateTime: 12/31/9999
*/
using System;
using System.Globalization;
public class SamplesCalendar {
public static void Main() {
// Create an instance of the calendar.
GregorianCalendar myCal = new GregorianCalendar();
Console.WriteLine( myCal.ToString() );
// Display the MinSupportedDateTime.
DateTime myMin = myCal.MinSupportedDateTime;
Console.WriteLine( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMin), myCal.GetDayOfMonth(myMin), myCal.GetYear(myMin) );
// Display the MaxSupportedDateTime.
DateTime myMax = myCal.MaxSupportedDateTime;
Console.WriteLine( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMax), myCal.GetDayOfMonth(myMax), myCal.GetYear(myMax) );
}
}
/*
This code produces the following output.
System.Globalization.GregorianCalendar
MinSupportedDateTime: 01/01/0001
MaxSupportedDateTime: 12/31/9999
*/
Imports System.Globalization
Public Class SamplesCalendar
Public Shared Sub Main()
' Create an instance of the calendar.
Dim myCal As New GregorianCalendar()
Console.WriteLine(myCal.ToString())
' Display the MinSupportedDateTime.
Dim myMin As DateTime = myCal.MinSupportedDateTime
Console.WriteLine("MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMin), myCal.GetDayOfMonth(myMin), myCal.GetYear(myMin))
' Display the MaxSupportedDateTime.
Dim myMax As DateTime = myCal.MaxSupportedDateTime
Console.WriteLine("MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMax), myCal.GetDayOfMonth(myMax), myCal.GetYear(myMax))
End Sub
End Class
'This code produces the following output.
'
'System.Globalization.GregorianCalendar
'MinSupportedDateTime: 01/01/0001
'MaxSupportedDateTime: 12/31/9999