Get user specified long date format in UWP

2020-05-01 01:49发布

I want to convert a date to the user set long date format. The Current Culture is en-US, but the user is able to set a long date format of his/her choice in Control panel -> Region -> Long Date.

In this case, here I set the Format to Hungarian, and selected the yyyy. MMMM d. format (keeping the Current Culture in en-US).

System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern returns an incorrect pattern.

So does the Windows.​Globalization API.

In my Package.appxmanifest:

  <Resources>
    <Resource Language="x-generate" />
  </Resources>

Anyone knows how to get the date format from control panel -> region -> long date?

1条回答
小情绪 Triste *
2楼-- · 2020-05-01 02:07

Unfortunately, the UWP API's don't expose the Regional Settings; having said that I did find a working solution a while back, though I haven't tested it with Creators Update so can't confirm if it still works!

Update: I've found a non-hacky way of doing this, using the GetLocaleInfoEx Win32 API.

查看更多
登录 后发表回答