How to convert String into DateFormat in java? -


I am working on Java. I have a string and I want to convert it to date format. Please see the code line for more details.

  string dateString = "4:16:06 pm";   

I want to change it to date below:

  date changed date = 2014-04-22 16:16 : 06.00   

How can I do this?

Try this: // Get the current date SimpleDateFormat DateFormat1 = new Simple Format ("yyyy-MM-dd") format; String A = Dateform 1 Format (new date ()); // Add a current date to your time string string dateString = a + "4:16:06 PM"; SimpleDetform FormatDormat2 = New SimpleDatormat ("YYA-MM-DD H: mm: SSA"); Try {// Pars it. It is the date object you date d = dateFormat2.parse (dateString); } Hold (ParseException pre) {ex.printStackTrace (); }

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -