get Start Of This Week In Milliseconds - Android java.util

Android examples for java.util:Millisecond

Description

get Start Of This Week In Milliseconds

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static long getStartOfThisWeekInMilli() {
        Calendar cal = initClearDayCal();
        cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
        return cal.getTimeInMillis();
    }//  w  ww . java2s  .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