Zer0 Zer0 - 1 year ago 89
Java Question

Java converting string, having millisecond to date object

I have 2 Strings

  • 2012-06-25 15:02:22.948

  • +0530

I need a new string which adds the 5:30 to the time in the first string.

I thought I can do this by converting both strings to date objects and then adding. But i dont know how to do it, as when i use

yyyy MM dd hh:mm:ss as the date format for the first string, I get an error.


Answer Source

You can merge both you string String1+string2 and can use format yyyy-MM-dd HH:mm:ss.SSSZ to parse the date. You can see more documentation here

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