Explicitly using withLocale
to set the locale to German results in the am/pm string being localized in the time value, but does not convert to the 24 hour time format which is correct for that locale.
When a new process is created, with the Locale.setLocale(Locale.GERMAN);
having been done, the format is correct.
Shouldn't withLocale()
affect all aspects of the locale in question?
// Code snippet where call is being made:
Log.d(TAG, "XYZZY getDefault(): " + Locale.getDefault().toString());
DateTimeFormatter timeFormat = DateTimeFormat.shortTime()
.withLocale(Locale.getDefault());
Log.d(TAG, "XYZZY timeFormat.locale: " +
timeFormat.getLocale().toString());
dateString = alarmTime.toString(timeFormat);
Log.d(TAG, "XYZZY dateString: "+ dateString);
When the variable alarmTime
has a value of 11:00pm (2300 hours):
10-04 14:17:41.492 (23609): XYZZY getDefault(): en_US
10-04 14:17:41.493 (23609): XYZZY timeFormat.locale: en_US
10-04 14:17:41.495 (23609): XYZZY dateString: 11:00 PM
Now switch over to German locale and reexecute the same code, note the string for 'PM' changes to German, but not the time format (the suffix should be suppressed and the time value should be 23:00):
10-04 14:18:15.066 (23609): XYZZY getDefault(): de_DE
10-04 14:18:15.066 (23609): XYZZY timeFormat.locale: de_DE
10-04 14:18:15.067 (23609): XYZZY dateString: 11:00 nachm.
Wait for the process to go away and be restarted, leaving the locale as German, and now the correct time format for German is returned:
10-04 14:18:54.497 (23881): XYZZY getDefault(): de_DE
10-04 14:18:54.497 (23881): XYZZY timeFormat.locale: de_DE
10-04 14:18:54.498 (23881): XYZZY dateString: 23:00