List of utility methods to do Calendar Create
Calendar | getCalendar(int year, int month, int date) Creates a Calender instance using the year, month, date arguments. Calendar cal = Calendar.getInstance();
cal.set(year, month, date);
setTimePart(cal);
return cal;
|
Calendar | getCalendar(int year, int month, int day) Get Calendar instance by specified year, month and day. if (year < 2000 || year > 2100) throw new IllegalArgumentException(); if (month < 1 || month > 12) throw new IllegalArgumentException(); if (day < 1) throw new IllegalArgumentException(); if (month == 2 && isLeapYear(year)) { if (day > 29) ... |
Calendar | getCalendar(int year, int month, int day) Create a calendar object for the given parameters. Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.set(year, month - 1, day);
return calendar;
|
Calendar | getCalendar(int year, int month, int day, int hour, int min, int sec, String timezone) get Calendar return getCalendar(year, month, day, hour, min, sec, TimeZone.getTimeZone(timezone));
|
GregorianCalendar | getCalendar(int year, int month, int day, int hour, int mins, int secs) Constructs a calendar object representing the given time GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, mins);
cal.set(Calendar.SECOND, secs);
cal.set(Calendar.MILLISECOND, 0);
...
|
GregorianCalendar | getCalendar(int year, int month, int day, int hours, int minutes, int seconds, TimeZone tz) Gets a Calendar object with a specific timezone GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(tz); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); cal.set(Calendar.DAY_OF_MONTH, day); cal.set(Calendar.HOUR_OF_DAY, hours); cal.set(Calendar.MINUTE, minutes); cal.set(Calendar.SECOND, seconds); cal.set(Calendar.MILLISECOND, 0); ... |
Calendar | getCalendar(int year, int month, int day, TimeZone timeZone) get Calendar Calendar date = Calendar.getInstance();
date.clear();
date.setTimeZone(timeZone);
date.set(year, month, day);
return date;
|
Calendar | getCalendar(long millis) get Calendar Calendar cal = Calendar.getInstance(); cal.setTime(new Date(millis)); return cal; |
Calendar | getCalendar(long millis) get Calendar Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(millis);
return cal;
|
Calendar | getCalendar(long time) Returns a Calendar instance for the given time Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date(time)); return calendar; |