.NET (3.5) formats times using dots instead of colons as TimeSeparator for it-IT culture?(.NET (3.5) 使用点而不是冒号来格式化时间作为 IT 文化的 TimeSeparator?)
问题描述
根据 维基百科(并在 达里奥·索莱拉的回答),他们在意大利使用冒号格式化时间:
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.
但是,运行以下代码似乎会输出点:
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 中,您发布的代码按预期使用冒号.框架版本之间似乎有一个奇怪的突破性变化,但升级到 .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) 使用点而不是冒号来格式化时间作为 IT 文化的 TimeSeparator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:.NET (3.5) 使用点而不是冒号来格式化时间作为 IT 文化的 TimeSeparator?


- 带问号的 nvarchar 列结果 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- 使用 rss + c# 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01