Java Calendar Day dayPrecision(Calendar calendar)

Here you can find the source of dayPrecision(Calendar calendar)

Description

Remove precision from a calendar so that it represents just a day.

License

Open Source License

Parameter

Parameter Description
calendar calendar

Return

new cal

Declaration

public static Calendar dayPrecision(Calendar calendar) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

public class Main {
    /**//from  w ww  . ja v a2s. c  o m
     * Remove precision from a calendar so that it represents just a day. A new
     * instance is returned
     * 
     * @param calendar calendar
     * @return new cal
     */
    public static Calendar dayPrecision(Calendar calendar) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(calendar.getTime());
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        return cal;
    }
}

Related

  1. dayDistance(Calendar date1, Calendar date2)
  2. dayEndTime(Calendar calendar)
  3. dayFloor(Calendar calendar)
  4. dayIterable(Calendar from, Calendar to)
  5. dayMarkToCalendar(int day)
  6. daysFromBinStart(Calendar date)
  7. daysSinceTheJesus(Calendar cal)
  8. dayStart(Calendar date)
  9. dayStart(final Calendar cal)