Question

I'm currently using the following code to format time on Google Android:

DateFormat.getDateTimeInstance().format(millis)

While this code honors my timezone and locale settings, it ignores the '24 hour mode' setting in system preferences, always returning time in AM/PM. Is there any way to get time in the same format as that on the status bar?

Was it helpful?

Solution

In theory (never tried this yet), you can use

http://developer.android.com/reference/android/text/format/DateFormat.html

To get formatters based on your settings. YMMV.

OTHER TIPS

SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm");
df.format(new Date(date));

"date" in millisec

Use the java.text.SimpleDateFormat class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top