Oktay Alizada Oktay Alizada - 1 year ago 68
Java Question

Java date format - GMT +04:00

I have to parse the following date

Fri Sep 30 18:31:00 GMT+04:00 2016

and it is not working with the following pattern:

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

Could you please tell me what I am doing wrong?

Answer Source

It should be lower case "y":

EEE MMM dd HH:mm:ss z yyyy

Upper case "Y" means weekBasedYear:

a date can be created from a week-based-year, week-of-year and day-of-week

I guess mixing the week-based and absolute/era patterns just does not work well for parsing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download