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
Post a Comment