C#DateTimeFormatInfo类

CultureInfo类格式列表

DateTimeFormatInfo类格式列表

 1 class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             DateTime dt = DateTime.Now;
 6             DateTimeFormatInfo dfi = new DateTimeFormatInfo();
 7             CultureInfo ci = new CultureInfo("nl-BE");
 8 
 9             //use the DateTimeFormat from the culture associated with
10             //the current thread
11             Console.WriteLine(dt.ToString("d"));
12             Console.WriteLine(dt.ToString("D"));
13 
14             //use the DateTimeFormat from the specific culture passed
15             Console.WriteLine(dt.ToString("F", ci));
16 
17             //make up a new custom DateTime pattern, ans use it
18             dfi.MonthDayPattern = "MM-MMMM, ddd-dddd";
19             Console.WriteLine(dt.ToString("m", dfi));
20 
21             //reset the current thread to a different culture
22             Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-BE");
23             Console.WriteLine(dt.ToString("d"));
24 
25         }

 

posted on 2013-12-14 00:49  jec  阅读(3375)  评论(0编辑  收藏  举报

导航