I have a timestamp field of Oracle in Java String
String strDate = “24.12.12 03:30:00,000”; //Timestamp field of Oracle
I need to convert it to Java.util.Date.
Please tell me a way to do this.
Note: I don’t have first two digits for the year, how can java understand that this is year 1912 or 2012 and so on.
The class you want is SimpleDateFormat. You’ll create a pattern that matches your expected input, and parse it. Here’s an example, though it may be incorrect in some places (I used 0-23 hour, maybe you want 1-24, etc.)
Regarding your 1912 vs 2012 problem, Java will make some assumptions when there are only 2 digits. Specifically: