Java Utililty Methods Calendar Create

List of utility methods to do Calendar Create

Description

The list of methods to do Calendar Create are organized into topic(s).

Method

CalendargetCalendarInstance()
Locale?
final Calendar cal = Calendar.getInstance();
return cal;
CalendargetCalendarOf(int slot)
get Calendar Of
Calendar c = Calendar.getInstance();
int minutes = slot * MINUTES_IN_ONE_TIME_SLOT;
c.set(Calendar.HOUR_OF_DAY, minutes / 60);
c.set(Calendar.MINUTE, minutes % 60);
return c;
Calendar[]getCalendarRange(Calendar date, int i)
Get date range ("20090101", 1) => Calendar[2] = { CalendarStart( "20090101 00:00:00") , CalendarEnd("20090102 00:00:00") }
if (null == date) {
    return null;
Calendar dateStart = getFirstMinuteOfDay(date);
Calendar dateEnd = Calendar.getInstance();
dateEnd.setTime(date.getTime());
dateEnd.add(Calendar.DAY_OF_WEEK, i);
dateEnd = getFirstMinuteOfDay(dateEnd);
...
StringgetCalendarTime(long timestamp)
Formats timestamp (in seconds since Unix epoch) into human-readable format of MMM DD YYYY hh:mm:ss.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timestamp * 1000);
String calTime = MONTHS[calendar.get(Calendar.MONTH)] + " " + calendar.get(Calendar.DATE) + " "
        + calendar.get(Calendar.YEAR) + " ";
calTime += addLeadingZero(calendar.get(Calendar.HOUR_OF_DAY)) + ":";
calTime += addLeadingZero(calendar.get(Calendar.MINUTE)) + ":";
calTime += addLeadingZero(calendar.get(Calendar.SECOND));
return calTime;
...
CalendargetCalendarTodayZero(Calendar today)
Returns the calendar from today with the first hour, minute, second and millisecond.
Calendar calendarZero = new GregorianCalendar(Locale.getDefault());
calendarZero.set(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DATE), 0, 0, 0);
calendarZero.set(Calendar.MILLISECOND, 0);
return calendarZero;
intgetCalendarTypeForString(String oneChar)
get Calendar Type For String
int calType = -1;
switch (oneChar.charAt(0)) {
case 'G':
    calType = Calendar.ERA;
    break;
case 'y':
    calType = Calendar.YEAR;
    break;
...
CalendargetLocalCalendar()
get Local Calendar
Calendar cal = localCalendar.get();
if (cal == null) {
    cal = Calendar.getInstance();
    localCalendar.set(cal);
return cal;
CalendargetLocalCalendar()
get Local Calendar
Calendar res = localCalendar.get();
if (res == null) {
    res = (Calendar) staticCalendar.clone();
    localCalendar.set(res);
return res;