Java – this “date”: “2014-08-20 00:00:00 -0500”? What is the time format

this “date”: “2014-08-20 00:00:00 -0500”? What is the time format… here is a solution to the problem.

this “date”: “2014-08-20 00:00:00 -0500”? What is the time format

I tried converting this date by:

SimpleDateFormat fromFormat  = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSSZ");

But I got :

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


“-0500” is the offset from UTC in RFC822 format. You only need Z, no SSS.

Android SimpleDateFormat docs In the table like this:

  • Symbol: Z
  • What it means: Time zone (RFC 822).
  • Kind: (time zone).
  • Example: Z/ZZ/ZZZ:-0800 ZZZZ:GMT-08:00

  • ZZZZZ:-08:00

Of course, I also specify the locale myself: this is a machine-readable format, not a human-facing format, so I usually specify Locale.US:

SimpleDateFormat format  = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z",
String text = "2014-08-20 00:00:00 -0500";

Related Problems and Solutions