Android examples for java.util:Date Parse
Parse date value in yyyy-MM-dd HH:mm format and return long number
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main{ public static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm"); public static long getTimeOfDate(String dateTime) { try {/*from w w w . j av a 2 s .co m*/ Date parse = dateFormat.parse(dateTime); long time = parse.getTime(); return time; } catch (ParseException e) { e.printStackTrace(); } return 0; } }