0

I just installed the upgrade version Lollipop on my android phone and this doesn't work anymore:

String time = "Apr 07 10:35:27 CEST 2015";
long l1 = new SimpleDateFormat("MMM dd HH:mm:ss zzz yyyy").parse(time).getTime();

long l2 = new SimpleDateFormat("MMM dd HH:mm:ss zzz yyyy",
                Locale.ENGLISH).parse(time).getTime();

Both doesn't work:

W/System.err(11473): java.text.ParseException: Unparseable date: "avr. 07 10:35:27 CEST 2015" (at offset 17)

The problem is that SimpleDateFormat now returns GMT+02:00 instead of previously CEST after I installed 5.0

Cœur
  • 37,241
  • 25
  • 195
  • 267
Waroulolz
  • 297
  • 9
  • 23
  • the posted code does not produce the given error. `avr.` is a/ french and b/ not a format recognized by the `MMM` token. `Avr` would, if you pass Locale.FRENCH to the formatter. – njzk2 Apr 12 '15 at 00:23
  • I'm on a french phone I don't know, anyway Locale.FRENCH doesn't solve anything. The problem is CEST became GMT+02:00 after I installed 5.0 – Waroulolz Apr 12 '15 at 00:26
  • where do you get that date from? – njzk2 Apr 12 '15 at 01:07
  • `CEST became GMT+02:00` I don't understand what you mean – njzk2 Apr 12 '15 at 01:08

1 Answers1

1

"CEST" is not a recognized timezone pattern according to CLDR, which Android uses. It may be that it was recognized in prior because SimpleDateFormat was lifted from Apache Harmony, which followed Java's own time format standard.

Kai
  • 15,284
  • 6
  • 51
  • 82
  • So I should consider having only the "GMT+02:00" models and no more consider CEST at all ? My only objective is to get precision dates. – Waroulolz Apr 12 '15 at 00:56
  • You may find this helpful: http://stackoverflow.com/questions/2532729/daylight-saving-time-and-time-zone-best-practices – Kai Apr 12 '15 at 01:07