Skip to content Skip to sidebar Skip to footer

Timezone Broken In Simpledateformat In Android 2.3

Android 2.3 was recently released last night. So naturally I tried my app on it and found there was date formatting issue. I have noticed the DateFormatter produces different form

Solution 1:

There is nothing wrong with the output. You create a DateFormat-Instance which depends on the default Locale. It is not unusual that on different machines, different java-installations the default Locale vary and so the output of locale-dependent operations. In this case the default TimeZone is different, but the two outputs in your question represent the same Date, printed with the same format String MMMMM d, yyyy hh:mm:ss a z.

UPDATE: parse() in Android 2.3 will work with TimeZones like GMT+xxxx etc, but it doesn't recognize EST for example as a valid TimeZone for parsing. Android knows about EST if you use TimeZone.getTimeZone("EST").

UPDATE2:

Three-letter timezone IDs "EST", "HST", and "MST" are deprecated. Do not use them.

Solution 2:

Both are same TimeZone just different representation

Solution 3:

Looks like support for pattern "EEE MMM dd HH:mm:ss zzz yyyy" is also broken.

Evgueni

Post a Comment for "Timezone Broken In Simpledateformat In Android 2.3"