Here you can find the source of clearDay(long timeInMillis)
public static long clearDay(long timeInMillis)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static long clearDay(long timeInMillis) { /*/*from w ww .j a va2 s . com*/ final int offset = timeZone.getOffset( timeInMillis ); timeInMillis += offset; return (timeInMillis / aDAY) * aDAY; */ Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timeInMillis); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.HOUR_OF_DAY, 0); return cal.getTimeInMillis(); } }