java string型时间转long

SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd H:m:s");
Date date=null;
try {
date = format.parse("2018-06-26 13:07:47");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Calendar cal = Calendar.getInstance();
cal.setTime(date);
long time=cal.getTimeInMillis();
System.out.println(time);

posted @ 2018-06-26 17:16  裸奔到月球  阅读(479)  评论(0编辑  收藏  举报