How to use the date format that has been setup as default in Settings?

十年热恋 提交于 2019-12-12 10:39:24

问题


As you probably know, you can setup date format in the Settings of an Android device.

In code how do we make sure that we use that format for date display?


回答1:


Try android.text.format.DateFormat, notably getDateFormatOrder() to get the user's preferred date format.




回答2:


You can retrieve both the date format as well as the time format like this:

DateFormat timeFormat;
DateFormat dateFormat;

dateFormat = android.text.format.DateFormat.getDateFormat(context);
timeFormat = android.text.format.DateFormat.getTimeFormat(context);


来源:https://stackoverflow.com/questions/2835425/how-to-use-the-date-format-that-has-been-setup-as-default-in-settings

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