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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -