Java Calendar Month setDate(Calendar cal, int month, int date, boolean endOfDay)

Here you can find the source of setDate(Calendar cal, int month, int date, boolean endOfDay)

Description

set Date

License

LGPL

Declaration

static void setDate(Calendar cal, int month, int date, boolean endOfDay) 

Method Source Code

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

import java.util.Calendar;

public class Main {
    static void setDate(Calendar cal, int month, int date, boolean endOfDay) {

        cal.clear();/*from  ww w . j  a  v a 2  s  .c  om*/

        cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR));
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.DATE, date);

        if (endOfDay) {
            cal.set(Calendar.HOUR_OF_DAY, 23);
            cal.set(Calendar.MINUTE, 59);
            cal.set(Calendar.SECOND, 59);
            cal.set(Calendar.MILLISECOND, 999);
        } else {
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);
        }
    }
}

Related

  1. month(Calendar calendar)
  2. month(Calendar date)
  3. numberOfDaysInMonth(Calendar cal)
  4. sameMonth(Calendar one, Calendar two)
  5. setDate(Calendar cal, int month, int date)
  6. setDate(Calendar calendar, int month, int date)
  7. setTimeAsFirstDayOfMonth(Calendar calendar)
  8. subtractMonths(Calendar date, int months)