Here you can find the source of getTimeByStr(String str)
public static long getTimeByStr(String str)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String PARSE_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static long getTimeByStr(String str) { SimpleDateFormat sdf = new SimpleDateFormat(PARSE_DATE_FORMAT); Date date;/* w w w.j a v a2s .c om*/ try { date = sdf.parse(str); return date.getTime(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); return System.currentTimeMillis(); } } }