android - How to display date/time according to device settings -


i want display date/time according device locale and settings 12h/24h mode.

having take @ several posts here on so, tried use this:

long millis = this.startdate.gettime(); if (dateformat.is24hourformat(context)) { // why have check ?!?     strdate = dateutils.formatdatetime(context, millis, dateutils.format_show_date | dateutils.format_show_year | dateutils.format_show_time | dateutils.format_24hour); } else {     strdate = dateutils.formatdatetime(context, millis, dateutils.format_show_date | dateutils.format_show_year | dateutils.format_show_time); } 

unfortunately, dateutils.format_24hour deprecated so, wonder how display date taking care of device local , settings?

so simpledateformat not expected answer don't want specify format myself.

try android.text.format.dateformat, notably getdateformatorder() user's preferred date format.


Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -