I'm trying to format dates and times exactly as specified by the user on the "Region and Language" page of the Windows Control Panel. This works semi-automatically for most selections the user makes as long as I use the general formatting strings, like "g" for general short date/time.
But I've encountered at least one exception. If I select Format: "English (United States)" and Short time: "hh:mm tt", then the formatting ignores the "hh" part and instead uses "h:mm tt", i.e., no leading zero for a single-digit hour.
// Just testing - to be removed
string s1 = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
string s2 = CultureInfo.CurrentUICulture.DateTimeFormat.ShortTimePattern;
Adding the above code to my program confirms that .Net is using "h:mm tt" instead of "hh:mm tt" as specified on the Control Panel page.
Is there something I can do to get it to use the specified setting, or to determine the setting myself and then explicitly get the formatting to use "hh:mm tt"?