Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Coverts the specified date/time value to specific milliseconds. * * @param str to convert into specific date/time. * @return converted milliseconds value. */ public static long getDateTimeinMilliSeconds(String str) { long milliseconds = 0; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //formatter.setTimeZone(TimeZone.getTimeZone("UTC")); Date startdate = null; try { startdate = formatter.parse(str); milliseconds = startdate.getTime(); } catch (ParseException e) { e.printStackTrace(); } return milliseconds; } }