Waylander Waylander - 1 year ago 49
Java Question

How can I correctly parse this kind of date?

I could not find a correctly and clean working solution for my Date which is formatted like this:


(8th of June, 21:59 here)

Last I tried was this:

SimpleDateFormat format2 = new SimpleDateFormat("YYYYMMDDHHMM", Locale.ENGLISH);

Sadly it's not working and printing out

Sun Dec 29 21:00:00 CET 2013

Answer Source

Minutes are set up by m not M

Years are set up by y not Y

Days (in month) are set up by d not D (in year)

SimpleDateFormat format2 = new SimpleDateFormat("yyyyMMddHHmm", Locale.ENGLISH);