/** * 将时间字符串转化为时间戳 */ public static long getStringToLong(String str) { // String time = "2010-11-20 11:10:10"; Date date = null; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { date = formatter.parse(str); return date.getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; } }