且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将字符串Date转换为long millseconds

更新时间:2023-11-06 18:50:34

使用 SimpleDateFormat

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();
}