Java Date to Calendar getCalendar(boolean dateAndTime)

Here you can find the source of getCalendar(boolean dateAndTime)

Description

get Calendar

License

Open Source License

Declaration

public static Calendar getCalendar(boolean dateAndTime) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static Calendar getCalendar(boolean dateAndTime) {
        Calendar cal = Calendar.getInstance();
        cal.set(2010, 1, 1, 0, 0, 0);//  w  ww.j av a 2 s .c  o  m
        cal.set(Calendar.MILLISECOND, 0); // We do not preserve ms resolution
        if (!dateAndTime) {
            // calendar w/ date only
            return cal;
        } else {
            // add some time to it too
            cal.set(Calendar.HOUR_OF_DAY, 10);
            cal.set(Calendar.MINUTE, 20);
            cal.set(Calendar.SECOND, 30);
            cal.set(Calendar.MILLISECOND, 0); // We do not preserve ms resolution
            return cal;
        }
    }
}

Related

  1. DateToCalendar(Date date)
  2. dateToGregorianCalendar(Date date)
  3. getCalendar(Date date)
  4. getCalendar(final Date date, final boolean stripTime)
  5. getCalendar(String dateString)
  6. newCalendar(Date date)