Android examples for java.util:Date Parse
Parse time String in yyyy-MM-dd HH:mm:ss format To date in long value
import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main{ public static long timeStringToMilis(String time) { long milis = 0; try {//from w w w . j a va 2s. c o m SimpleDateFormat sd = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); Date date = sd.parse(time); milis = date.getTime(); } catch (Exception e) { e.printStackTrace(); } return milis; } }