Skip to content
Advertisement

Convert date in string(Mon Jan 16:20:12 India Standard Time 2014) to java.util.date in JAVA

I want to convert this (Mon Jan 16:20:12 India Standard Time 2014) Date in string to java.util.Date in java how can I do it. I want the date in the following format.

JavaScript

Actually the Date (Mon Jan 16:20:12 India Standard Time 2014) is argument from MFC application which will be launching a executable jar file and the date in string will be its argument. MFC Code that will launch the executable jar. with argument.

JavaScript

Also will it be possible to get the date with spaces as single argument in java. Please Help me, am new to MFC.

Advertisement

Answer

You need to use another SimpleDateFormat that has the format of your time-string to do the parsing. For your example, this one should work:

JavaScript

As @TimB points out, all the date and time patterns can be found in the JavaDoc for SimpleDateFormat.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement