C# windows版本之间的CultureInfo不一致 有人注意到在不同版本的Windows上,CultureInfo格式会产生不同的模式吗?
Windows 7已创建dddd、MMMM dd、YYYY 样本输出: Windows 10和Windows Server 2012都创建了dddd、MMMM和YYYY 样本输出: & 我是从银行拿到这个样品的。修改为检查一天的前导零C# windows版本之间的CultureInfo不一致 有人注意到在不同版本的Windows上,CultureInfo格式会产生不同的模式吗?,c#,.net,windows,cultureinfo,windows-server-2012-r2,C#,.net,Windows,Cultureinfo,Windows Server 2012 R2,Windows 7已创建dddd、MMMM dd、YYYY 样本输出: Windows 10和Windows Server 2012都创建了dddd、MMMM和YYYY 样本输出: & 我是从银行拿到这个样品的。修改为检查一天的前导零 public class Sample { public static void Main() { string msg1 = "The date and time patterns are defined in the Dat
public class Sample
{
public static void Main()
{
string msg1 = "The date and time patterns are defined in the DateTimeFormatInfo \n" +
"object associated with the current thread culture.\n";
// Initialize a DateTime object.
Console.WriteLine("Initialize the DateTime object to May 06, 2001 3:02:15 AM.\n");
DateTime myDateTime = new System.DateTime(2001, 5, 6, 3, 2, 15);
// Identify the source of the date and time patterns.
Console.WriteLine(msg1);
// Display the name of the current culture.
CultureInfo ci = CultureInfo.GetCultureInfo("en-us");
Console.WriteLine("Current culture: \"{0}\"\n", ci.Name);
// Display the long date pattern and string.
Console.WriteLine("Long date pattern: \"{0}\"", ci.DateTimeFormat.LongDatePattern);
Console.WriteLine("Long date string: \"{0}\"\n", myDateTime.ToLongDateString());
// Display the long time pattern and string.
Console.WriteLine("Long time pattern: \"{0}\"", ci.DateTimeFormat.LongTimePattern);
Console.WriteLine("Long time string: \"{0}\"\n", myDateTime.ToLongTimeString());
// Display the short date pattern and string.
Console.WriteLine("Short date pattern: \"{0}\"", ci.DateTimeFormat.ShortDatePattern);
Console.WriteLine("Short date string: \"{0}\"\n", myDateTime.ToShortDateString());
// Display the short time pattern and string.
Console.WriteLine("Short time pattern: \"{0}\"", ci.DateTimeFormat.ShortTimePattern);
Console.WriteLine("Short time string: \"{0}\"\n", myDateTime.ToShortTimeString());
Console.ReadLine();
}
}
此外,在Windows 10上还有更多的CultureInfo可用。我希望这将与Windows Server 2016保持一致,最好通过WU推广到所有版本 比如,;Windows 10支持
247个地区
,其中Windows 2012R2仅支持142个地区
CultureInfo对象分为多个区域:
视窗10
Windows 2012R2
来自文化信息文档:“除了不变的区域性之外,区域性数据是动态的。即使对于预定义的文化也是如此。例如,国家或地区采用新货币、更改单词拼写或更改首选日历,而文化定义也会随之改变。自定义区域性会随时更改,恕不另行通知,并且任何特定区域性都可能被自定义替换区域性覆盖。此外,如下文所述,单个用户可以覆盖文化偏好。应用程序应始终在运行时获取区域性数据。“@MikeZboray,我惊讶地发现,en NZ将TShortTimeStrting的模式“tt”从“a.m./p.m.”更改为“AM/PM”,我花了大量时间查看.Net公告和文档,以找出在Windows 10和Windows Server 2016(或更早版本的Windows Server)中引入该更改的任何迹象。但事实上,
它们可能会在未经通知的情况下更改。