Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static long setTimeToMidnightAndGet(Calendar cal, long epoch) { cal.setTime(new Date(epoch)); 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(); } }