.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?


基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01