get Start Of Today In Milliseconds - Android java.util

Android examples for java.util:Millisecond

Description

get Start Of Today In Milliseconds

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static long getStartOfTodayInMilli() {
        Calendar cal = initClearDayCal();
        return cal.getTimeInMillis();
    }//from ww w .ja va  2 s  .  c o m

    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;
    }
}

Related Tutorials