.NET (3.5) formats times using dots instead of colons as TimeSeparator for it-IT culture?

后端 未结 4 729
夕颜
夕颜 2020-11-30 15:40

According to Wikipedia (and confirmed in an answer by Dario Solera), in Italy they format times using colons:

The 24-hour notation is used in writing

4条回答
  •  执念已碎
    2020-11-30 15:50

    Following from the conversation under Oded's answer, this is probably what you should be using:

    var culture = CultureInfo.GetCultureInfo("it-IT");
    var stringValue = new TimeSpan(100, 100, 100, 100, 100).ToString(null, culture);
    var timespan = TimeSpan.Parse(stringValue, culture);
    // Another example
    var culture = CultureInfo.GetCultureInfo("it-IT");
    var stringValue = DateTime.Now.ToString(null, culture);
    var dateTime = DateTime.Parse(stringValue, culture);
    

提交回复
热议问题