Here you can find the source of getDayStartTimestamp()
public static long getDayStartTimestamp()
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String DATE_FORMAT = "yyyy-MM-dd"; public static String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static long getDayStartTimestamp() { Timestamp[] timestamps = getDayStartEnd(); return Long.valueOf(dateToStamp(timestamps[0] + "")); }// w w w .j a va 2 s . c om public static Timestamp[] getDayStartEnd() { Timestamp[] t = new Timestamp[2]; String day = new SimpleDateFormat(DATE_FORMAT).format(Calendar.getInstance().getTime()); t[0] = Timestamp.valueOf(day + " 00:00:00"); t[1] = Timestamp.valueOf(day + " 23:59:59"); return t; } public static String dateToStamp(String date) { try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(TIME_FORMAT); Date date1 = simpleDateFormat.parse(date); long ts = date1.getTime() / 1000; return String.valueOf(ts); } catch (Exception e) { } return String.valueOf(getDateStamp() / 1000); } public static Timestamp getTime() { String day = new SimpleDateFormat(TIME_FORMAT).format(Calendar.getInstance().getTime()); return Timestamp.valueOf(day); } public static long getDateStamp() { return (long) System.currentTimeMillis() / 1000; } }