i have a string in a format i don't really recognize: string received: "36872 Dec 12 15:35" while the windows representation for this date is: "12/12/2012 5:35 PM"
so first, I'm guessing something was corrupted in the date. second, I'm looking to parse this string to a epoch time format
something like this: "1355371390142" (which is actually "2012-12-13 06:03:10")
You can format Date
s in Java like this:
String str = "12/12/2012 5:35 PM"; //Your String containing a date
DateFormat dF = new SimpleDateFormat("dd//MM/yyyy hh:mm a"); // The mask
// 'a' value in the Mask represents AM / PM - h means hours in AM/PM mode
Date date = dF.parse(str); // parsing the String into a Date using the mask
//Date.getTime() method gives you the Long with milliseconds since Epoch.
System.out.println("Epoch representation of this date is: " + date.getTime());
Refer to this for mask options: http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With