Java tutorial
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import android.text.TextUtils; public class Main { public static long getTimeMillis(String dateStr, String format) { return getDate(dateStr, format).getTime(); } public static Date getDate(String dateStr, String format) { if (TextUtils.isEmpty(dateStr) || TextUtils.isEmpty(format)) { return null; } Date date = null; try { SimpleDateFormat df = new SimpleDateFormat(format); date = df.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return date; } }