Android examples for java.util:Millisecond
get Yesterday Start In Milliseconds
//package com.java2s; import java.util.Calendar; public class Main { private static final long dayInMilli = 86400000; public static long getYesterdayStartInMilli() { return getStartOfTodayInMilli() - dayInMilli; }//from ww w.j av a 2 s. c o m public static long getStartOfTodayInMilli() { Calendar cal = initClearDayCal(); return cal.getTimeInMillis(); } private static Calendar initClearDayCal() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day ! cal.clear(Calendar.MINUTE); cal.clear(Calendar.SECOND); cal.clear(Calendar.MILLISECOND); return cal; } }