1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| using System; using System.Globalization;
public class Example { public static void Main() { string[] formats = {"d", "D", "f", "F", "g", "G", "m", "o", "r", "s", "t", "T", "u", "U", "Y"}; CultureInfo[] cultures = {CultureInfo.CreateSpecificCulture("zh-CN"), CultureInfo.CreateSpecificCulture("en-US")}; foreach (CultureInfo culture in cultures) { Console.WriteLine(culture.Name); foreach (string formatSpecifier in formats) { Console.WriteLine("{0} {1}", formatSpecifier, DateTime.Now.ToString(formatSpecifier, culture)); } Console.WriteLine(); } } }
|