如何将字符串Date转换为long millseconds [英] How to convert a string Date to long millseconds
本文介绍了如何将字符串Date转换为long millseconds的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在字符串中有一个日期,类似2012年12月12日。
如何将其转换为毫秒(长)?
I have a date inside a string, something like "12-December-2012". How can I convert this into milliseconds (long)?
推荐答案
String string_date = "12-December-2012";
SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
try {
Date d = f.parse(string_date);
long milliseconds = d.getTime();
} catch (ParseException e) {
e.printStackTrace();
}
这篇关于如何将字符串Date转换为long millseconds的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文