Here you can find the source of getTimeInMillis(String date)
@SuppressLint("SimpleDateFormat") public static long getTimeInMillis(String date)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import android.annotation.SuppressLint; public class Main { public static Calendar calendar = Calendar.getInstance(); @SuppressLint("SimpleDateFormat") public static long getTimeInMillis(String date) { Date currentDate;/*from w ww . ja va2s . c om*/ try { String format = "HH:mm"; if (date.contains("-")) { format = "yyyy-MM-dd HH:mm:ss"; } SimpleDateFormat dateForamt = new SimpleDateFormat(format); currentDate = dateForamt.parse(date); } catch (ParseException e) { e.printStackTrace(); currentDate = new Date(); } calendar.setTime(currentDate); return calendar.getTimeInMillis(); } }