Java Calendar Day getCanonicalDay(Calendar cal)

Here you can find the source of getCanonicalDay(Calendar cal)

Description

Returns the canonical day calendar for a given calendar, which is the first millisecond of the day (2008/03/07 15:23:32 992ms --> 2008/03/07 0:0:0 0ms)

License

Apache License

Parameter

Parameter Description
cal a parameter

Declaration

public static Calendar getCanonicalDay(Calendar cal) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    /**/*  ww w .  j  a  va  2  s  .c  om*/
     * Returns the canonical day calendar for a given calendar, which is the first millisecond of 
     * the day (2008/03/07 15:23:32 992ms --> 2008/03/07 0:0:0 0ms)
     * @param cal
     * @return 
     */
    public static Calendar getCanonicalDay(Calendar cal) {
        Calendar ret = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
                cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
        ret.set(Calendar.MILLISECOND, 0);
        ret.setTimeZone(cal.getTimeZone());
        return ret;
    }
}

Related

  1. dayStart(final Calendar cal)
  2. decreaseByDay(final Calendar calendar)
  3. endOfDay(Calendar calendar)
  4. getAge(Calendar dateOfBirth, Calendar onThisDay)
  5. getBeginDay(Calendar cal)
  6. getCanonicalDayFrom(Calendar day, int daysFrom)
  7. getCleanDay(Calendar c)
  8. getCurDay(Calendar calendar)
  9. getDay(Calendar cal)