Here you can find the source of getTimestampInDayFirstSecond(final Calendar calendar)
public static int getTimestampInDayFirstSecond(final Calendar calendar)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static final int MILLIS_PER_SECOND = 1000; public static int getTimestampInDayFirstSecond(final Calendar calendar) { Calendar other = (Calendar) calendar.clone(); other.set(Calendar.HOUR_OF_DAY, 0); other.set(Calendar.MINUTE, 0); other.set(Calendar.SECOND, 0); other.set(Calendar.MILLISECOND, 0); return getTimestamp(other.getTimeInMillis()); }//from w ww . jav a 2 s . co m public static int getTimestampInDayFirstSecond(int ts) { Calendar other = Calendar.getInstance(); other.setTimeInMillis(Integer.toUnsignedLong(ts) * MILLIS_PER_SECOND); other.set(Calendar.HOUR_OF_DAY, 0); other.set(Calendar.MINUTE, 0); other.set(Calendar.SECOND, 0); other.set(Calendar.MILLISECOND, 0); return getTimestamp(other.getTimeInMillis()); } public static int getTimestampInDayFirstSecond(long timeInMillis) { Calendar other = Calendar.getInstance(); other.setTimeInMillis(timeInMillis); other.set(Calendar.HOUR_OF_DAY, 0); other.set(Calendar.MINUTE, 0); other.set(Calendar.SECOND, 0); other.set(Calendar.MILLISECOND, 0); return getTimestamp(other.getTimeInMillis()); } public static int getTimestamp() { return (int) (System.currentTimeMillis() / MILLIS_PER_SECOND); } public static int getTimestamp(long timeInMillis) { return (int) (timeInMillis / MILLIS_PER_SECOND); } public static int getTimestamp(final Date date) { return (int) (date.getTime() / MILLIS_PER_SECOND); } }