Here you can find the source of dateTimeToMillis(String dateTime, String format)
public static long dateTimeToMillis(String dateTime, String format)
//package com.java2s; //License from project: LGPL import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static long dateTimeToMillis(String dateTime, String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); try {//from w w w.j a v a 2 s .co m return dateFormat.parse(dateTime).getTime(); } catch (ParseException e) { return -1; } } }