Wrong SimpleDateFormat parse

12 views
Skip to first unread message

Akinniranye James

unread,
Jun 13, 2017, 8:56:10 AM6/13/17
to CodenameOne Discussions
This  issue applies to:
IDE: NetBeans/Eclipse/IDEA
Simulator
Device

I ran this code on the above platform
String src = "2017-06-13T10:59:19.037+0100 Africa/Lagos";
SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ zzz");
Date parse = DATEFORMAT.parse(src);
System.out.println(parse);

Instead of getting Tue Jun 13 10:59:19 WAT 2017 I got Tue Jun 13 09:59:19 WAT 2017

Africa/Lagos and WAT are in the same timezone

Shai Almog

unread,
Jun 14, 2017, 12:22:14 AM6/14/17
to CodenameOne Discussions
Parsing with simple date format doesn't support all the various timezones since SimpleDateFormat doesn't have access to the full JavaSE timezone list.
Reply all
Reply to author
Forward
0 new messages