Get user specified long date format in UWP

好久不见. 提交于 2019-12-02 23:41:44

问题


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:


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.



来源:https://stackoverflow.com/questions/43675132/get-user-specified-long-date-format-in-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!