本文整理汇总了C#中System.Globalization.GregorianCalendar类的典型用法代码示例。如果您正苦于以下问题:C# GregorianCalendar类的具体用法?C# GregorianCalendar怎么用?C# GregorianCalendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GregorianCalendar类属于System.Globalization命名空间,在下文中一共展示了GregorianCalendar类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Globalization;
public class SamplesGregorianCalendar {
public static void Main() {
// Creates strings with punctuation and without.
String strADPunc = "A.D.";
String strADNoPunc = "AD";
String strCEPunc = "C.E.";
String strCENoPunc = "CE";
// Calls DTFI.GetEra for each culture that uses GregorianCalendar as the default calendar.
Console.WriteLine( " ----- AD ----- ----- CE -----" );
Console.WriteLine( "CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR" );
foreach ( CultureInfo myCI in CultureInfo.GetCultures( CultureTypes.SpecificCultures ) ) {
Console.Write( "{0,-12}", myCI );
Console.Write( "{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra( strADPunc ), myCI.DateTimeFormat.GetEra( strADNoPunc ) );
Console.Write( "{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra( strCEPunc ), myCI.DateTimeFormat.GetEra( strCENoPunc ) );
Console.Write( "{0}", myCI.Calendar );
Console.WriteLine();
}
}
}
输出:
----- AD ----- ----- CE ----- CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR ar-SA -1 -1 -1 -1 System.Globalization.HijriCalendar ar-IQ 1 1 -1 -1 System.Globalization.GregorianCalendar ar-EG 1 1 -1 -1 System.Globalization.GregorianCalendar ar-LY 1 1 -1 -1 System.Globalization.GregorianCalendar ar-DZ 1 1 -1 -1 System.Globalization.GregorianCalendar ar-MA 1 1 -1 -1 System.Globalization.GregorianCalendar ar-TN 1 1 -1 -1 System.Globalization.GregorianCalendar ar-OM 1 1 -1 -1 System.Globalization.GregorianCalendar ar-YE 1 1 -1 -1 System.Globalization.GregorianCalendar ar-SY 1 1 -1 -1 System.Globalization.GregorianCalendar ar-JO 1 1 -1 -1 System.Globalization.GregorianCalendar ar-LB 1 1 -1 -1 System.Globalization.GregorianCalendar ar-KW 1 1 -1 -1 System.Globalization.GregorianCalendar ar-AE 1 1 -1 -1 System.Globalization.GregorianCalendar ar-BH 1 1 -1 -1 System.Globalization.GregorianCalendar ar-QA 1 1 -1 -1 System.Globalization.GregorianCalendar bg-BG 1 1 -1 -1 System.Globalization.GregorianCalendar ca-ES -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-TW -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-CN -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-HK -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-SG 1 1 -1 -1 System.Globalization.GregorianCalendar zh-MO 1 1 -1 -1 System.Globalization.GregorianCalendar cs-CZ -1 -1 -1 -1 System.Globalization.GregorianCalendar da-DK 1 1 -1 -1 System.Globalization.GregorianCalendar
示例2: Main
//引入命名空间
using System;
using System.Globalization;
using System.Threading;
public class Example
{
public static void Main()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("da-DK");
JulianCalendar jc = new JulianCalendar();
DateTime lastDate = new DateTime(1700, 2, 18, jc);
Console.WriteLine("Last date (Gregorian): {0:d}", lastDate);
Console.WriteLine("Last date (Julian): {0}-{1}-{2}\n", jc.GetDayOfMonth(lastDate),
jc.GetMonth(lastDate), jc.GetYear(lastDate));
DateTime firstDate = lastDate.AddDays(1);
Console.WriteLine("First date (Gregorian): {0:d}", firstDate);
Console.WriteLine("First date (Julian): {0}-{1}-{2}", jc.GetDayOfMonth(firstDate),
jc.GetMonth(firstDate), jc.GetYear(firstDate));
}
}
输出:
Last date (Gregorian): 28-02-1700 Last date (Julian): 18-2-1700 First date (Gregorian): 01-03-1700 First date (Julian): 19-2-1700