Reputation: 37
How do I convert date string 'Fri Mar 14 09:44:31 IST 2014'
to millisec
?
I tried with this Java code:
String dateStr = "Fri Mar 14 09:44:31 IST 2014";
SimpleDateFormat sdf = new SimpleDateFormat("MM dd HH:MM:ss");
try {
System.out.println(sdf.parse(dateStr).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
Upvotes: 1
Views: 177
Reputation: 3456
your SimpleDateFormat
is not correct.
Try this
SimpleDateFormat sd = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
Upvotes: 2
Reputation: 167
try following code.
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US);
Upvotes: 1