normalize Calendar to clear time field - Java java.util

Java examples for java.util:Calendar Calculation

Description

normalize Calendar to clear time field

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar calc = Calendar.getInstance();
        normalizeCalendar(calc);/*from   ww  w .j  a va2 s . c  o  m*/
    }

    public static void normalizeCalendar(Calendar calc) {
        calc.set(Calendar.HOUR_OF_DAY, 0);
        calc.set(Calendar.MINUTE, 0);
        calc.set(Calendar.SECOND, 0);
        calc.set(Calendar.MILLISECOND, 0);
    }
}

Related Tutorials