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