.NET(3.5)格式使用点,而不是冒号倍TimeSeparator中它-IT文化? [英] .NET (3.5) formats times using dots instead of colons as TimeSeparator for it-IT culture?
问题描述
根据维基百科(在<一个确认href="http://stackoverflow.com/questions/7498058/net-formats-times-using-dots-instead-of-colons-for-it-it-culture/7511415#7511415">an达里奥索莱拉答案),在意大利他们使用冒号格式次:
According to Wikipedia (and confirmed in an answer by Dario Solera), in Italy they format times using colons:
24小时制采用的是书面冒号作为分隔符。 举例:14:05。会议记录由两位数字;小时 号码可以写入有或没有前导零。
The 24-hour notation is used in writing with a colon as a separator. Example: 14:05. The minutes are written with two digits; the hour numbers can be written with or without leading zero.
然而,运行以下code似乎输出点:
However, running the following code seems to output dots:
using System.Globalization;
Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("it-IT");
// Outputs "11.08"
Console.WriteLine(DateTime.Now.ToShortTimeString());
// Outputs "."
Console.WriteLine(new CultureInfo("it-IT").DateTimeFormat.TimeSeparator);
这是一个框架的错误?什么是修理它的最佳方法是什么? TimeSeparator中
可设置 - ?我们应该分配给前,只是将其覆盖 Thread.CurrentThread.CurrentCulture
等
Is this a framework bug? What's the best way to "fix" it? TimeSeparator
is settable - should we just overwrite it before assigning to Thread.CurrentThread.CurrentCulture
etc.?
推荐答案
这似乎是一个.NET 3.5的问题。在.NET 4.0中发布了code使用一个冒号预期。好像框架版本之间有奇怪的重大更改,但似乎是升级到.NET 4将解决这个问题。
This seems to be a .NET 3.5 issue. In .NET 4.0 the code you posted uses a colon as expected. Seems like a strange breaking change between the framework versions, but seems like upgrading to .NET 4 will solve the problem.
这篇关于.NET(3.5)格式使用点,而不是冒号倍TimeSeparator中它-IT文化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!