In a Windows Store app (8.1, non-UWP), how do I get the date and time formats as configured in Windows 10? In the following example, the operating system is installed with language en-US
and time and currency formats set to de-DE
.
I tried:
new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate"); // resolved language = en-US, resolved geographic region = ZZ ?!
Windows.Globalization.Language.CurrentInputMethodLanguageTag; // en-US
Windows.System.UserProfile.GlobalizationPreferences.Languages; // en-US
Windows.Globalization.ApplicationLanguages.Languages; // en-US
DateTime.Now.ToString(); // en-US
CultureInfo.CurrentCulture; // en-US
CultureInfo.CurrentUICulture; // en-US
new GeographicRegion().CodeTwoLetter; // DE, but: could be ch-DE, de-DE, xyz-DE ?!
I read this post on SO, but I fail to see how the highest voted answer will allow me to respect the date and time format set by the user (without doing wild guesses based on language preferences).
So, is there a way to format a DateTime
instance as expected in a Windows Store app?