views:

43

answers:

3

For example, I want to parse the string below:

Tue Sep 28 18:02:24 GMT+08:00 2010

And I use the pattern for the SimpleDateFormat:

new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzzzzzzz yyyy");

But I keep getting the ParseException. How to fix this?

Thanks a lot.

+1  A: 

Alright, I found the solution here.

new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);

But what's the difference between using 'z' and 'Z' here? Are they the same?

shiami
You hit the return a few sec. before. :)
Ido
z and Z are "general time zone" vs. "RFC 822 time zone"
Ido
Many thanks, Ido.
shiami
+2  A: 

use one z, as in the examples here

new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
Ido
A: 

Even if you have many z's it work.

Dheeraj Joshi
That's weird. It failed.
shiami
It is working for me.
Dheeraj Joshi