CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern in .Net 3.5?

In the settings for the region and language of Windows 7, my general "Format" is set to "English (USA)", but my individual patterns for dates and times are set as follows ...

Long Date: dddd, dd MMMM, yyyy

Short Date: MM/dd/yyyy

Long Time: HH:mm:ss

Short time: HH:mm

When I run the following aimed at .Net 4.0

 static void Main(string[] args) { Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern); Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern); Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern); Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern); } 

In the end, I get the results, as expected,

 dddd, dd MMMM, yyyy MM/dd/yyyy HH:mm:ss HH:mm 

But if I run it, targeting .Net 3.5 (or lower), I get:

 dddd, dd MMMM, yyyy MM/dd/yyyy HH:mm:ss h:mm tt 

You will notice that the long time format uses my selected Windows format, but the short one apparently uses the default value for "English (United States)".

Am I missing something?

+4
source share
1 answer

This seems to be a known issue in .NET 3.5. See Microsoft Connect Feedback Element:

http://connect.microsoft.com/VisualStudio/feedback/details/167791/datetime-now-tostring-t-not-following-custom-regional-settings

Feedback includes the proposed solution.

+1
source

Source: https://habr.com/ru/post/1395694/


All Articles