new Calendar For Day - Java java.util

Java examples for java.util:Day

Description

new Calendar For Day

Demo Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        Date date = new Date();
        System.out.println(newCalendarForDay(date));
    }/*from   ww w . ja  v a 2s.  c  o m*/

    public static Calendar newCalendarForDay(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.HOUR, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        return cal;
    }
}

Related Tutorials