Waylander Waylander - 3 months ago 10
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:

201406082159

(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

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); 

Source