Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static long getTime(String date) { try { return simpleDateFormat.parse(date).getTime(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return -1; } }