Here you can find the source of getTimestampFromDateString(String date)
public static long getTimestampFromDateString(String date) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /**/*from w w w. j a v a2 s.c o m*/ * This method computes the timestamp of the beginning of the day (UTC), given a random string yyyy-MM-dd **/ public static long getTimestampFromDateString(String date) throws ParseException { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); cal.setTime(sdf.parse(date)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return (cal.getTimeInMillis() / 1000L); } }