Here you can find the source of strToDateMillisTimestamp(String dateStr, String formatStr)
public static long strToDateMillisTimestamp(String dateStr, String formatStr)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long strToDateMillisTimestamp(String dateStr, String formatStr) { Date date = strToDate(dateStr, formatStr); return date != null ? date.getTime() : 0; }//from www. jav a2 s .c o m public static Date strToDate(String dateStr, String formatStr) { Date date = null; try { SimpleDateFormat format = new SimpleDateFormat(formatStr); date = format.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return date; } }