Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static long getMillisTimeStr(String time, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); try { long millis = sdf.parse(time).getTime(); return millis; } catch (ParseException e) { e.printStackTrace(); } return -1; } }