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();
}
your SimpleDateFormat
is not correct.
Try this
SimpleDateFormat sd = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
尝试以下代码。
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.