Sunday, 15 April 2012

java - What is the Time format for this "date": "2014-08-20 00:00:00 -0500"? -



java - What is the Time format for this "date": "2014-08-20 00:00:00 -0500"? -

i tried converting date next way:

simpledateformat fromformat = new simpledateformat("yyyy-mm-dd hh:mm:ss sssz");

but got:

java.text.parseexception: unparseable date: "2014-09-20 00:00:00 -0500" (at offset 20)

that "-0500" offset utc, in rfc822 format. want z, without sss.

the android simpledateformat docs have in table:

symbol: z meaning: time zone (rfc 822) kind: (time zone) example: z/zz/zzz:-0800 zzzz:gmt-08:00 zzzzz:-08:00

i specify locale, matter of course: machine-readable format rather human-oriented format, i'd specify locale.us:

simpledateformat format = new simpledateformat("yyyy-mm-dd hh:mm:ss z", locale.us); string text = "2014-08-20 00:00:00 -0500"; system.out.println(format.parse(text));

java android date

No comments:

Post a Comment