简体   繁体   中英

How to parse this date format

Hi folks I am trying to parse this format but not able to it .

Format : Fri Oct 21 2011 08:45:00 GMT 0530 (IST)

SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss zzz ZZZZ")

Can some one explain me what is wrong in this ?

The format for your zzz is incorrect; the docs show that it needs to be in this format: GMT-05:30 .

Also, since you have parentheses around the Z parameter, you need parentheses in your format string.

sdf = new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss z (Z)")
println sdf.parse("Fri Oct 21 2011 08:45:00 GMT+05:30 (IST)")
> Fri Oct 21 02:45:00 EDT 2011

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM