Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long getStringToDate(String time, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); Date date = new Date(); try { date = sdf.parse(time); } catch (ParseException e) { e.printStackTrace(); } return date.getTime(); } }