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

CalendargetCalendar(long timeInMillis)
Get Calendar object representing the specified time in millis.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timeInMillis);
return calendar;
CalendargetCalendar(long timeInMillis)
UNIX TIME(timeInMillis) to Calendar object
Calendar dest = Calendar.getInstance();
dest.setTimeInMillis(timeInMillis);
return dest;
CalendargetCalendar(String date)
get Calendar
Calendar ret = Calendar.getInstance();
ret.set(Integer.parseInt(date.substring(0, 4)), Integer.parseInt(date.substring(4, 6)) - 1,
        Integer.parseInt(date.substring(6, 8)), 0, 0, 0);
ret.set(Calendar.MILLISECOND, 0);
return ret;
CalendargetCalendar(String dateStr, int inputYearType, int outputYearType)
get Calendar
Vector d = getElementDate(dateStr);
int day = Integer.parseInt((String) d.elementAt(0));
int month = Integer.parseInt((String) d.elementAt(1));
int year = Integer.parseInt((String) d.elementAt(2));
switch (inputYearType) {
case EN:
    if (outputYearType == TH)
        year += 543;
...
CalendargetCalendar(String dateString)
get Calendar
Calendar calendar = Calendar.getInstance();
String[] items = dateString.split("[-| |:]");
int len = items.length;
if (len == 1) {
    String item = items[0];
    if (item.length() >= 4) {
        calendar.set(Calendar.YEAR, Integer.parseInt(item.substring(0, 4)));
    if (item.length() >= 6) {
        calendar.set(Calendar.MONTH, Integer.parseInt(item.substring(4, 6)) - 1);
    if (item.length() >= 8) {
        calendar.set(Calendar.DATE, Integer.parseInt(item.substring(6, 8)));
    if (item.length() >= 10) {
        calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(item.substring(8, 10)));
    if (item.length() >= 12) {
        calendar.set(Calendar.MINUTE, Integer.parseInt(item.substring(10, 12)));
    if (item.length() >= 14) {
        calendar.set(Calendar.SECOND, Integer.parseInt(item.substring(12, 14)));
} else {
    if (len > 1) {
        calendar.set(Calendar.MONTH, Integer.parseInt(items[1]) - 1);
    } else {
        calendar.set(Calendar.MONTH, 0);
    if (len > 2) {
        calendar.set(Calendar.DATE, Integer.parseInt(items[2]));
    } else {
        calendar.set(Calendar.DATE, 1);
    if (len > 3) {
        calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(items[3]));
    } else {
        calendar.set(Calendar.HOUR_OF_DAY, 0);
    if (len > 4) {
        calendar.set(Calendar.MINUTE, Integer.parseInt(items[4]));
    } else {
        calendar.set(Calendar.MINUTE, 0);
    if (len > 5) {
        calendar.set(Calendar.SECOND, Integer.parseInt(items[5]));
    } else {
        calendar.set(Calendar.SECOND, 0);
return calendar;
CalendargetCalendar(String gdate)
Get a Calendar for this gdate, or null in case of failure
return getCalendar(gdate, null);
CalendargetCalendar(String str)
get Calendar
int yy = Integer.parseInt(str.substring(0, 4));
int mm = Integer.parseInt(str.substring(4, 6)) - 1;
int dd = Integer.parseInt(str.substring(6, 8));
Calendar cal = Calendar.getInstance();
cal.set(yy, mm, dd);
return cal;
CalendargetCalendar(String time, char sep, boolean isStart)
get Calendar
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, isStart ? 0 : 23);
cal.set(Calendar.MINUTE, isStart ? 0 : 59);
cal.set(Calendar.SECOND, isStart ? 0 : 59);
cal.set(Calendar.MILLISECOND, isStart ? 0 : 999);
try {
    int idx = time.indexOf(sep);
    if (idx != -1) {
...
CalendargetCalendar(String yyyy, String mm, String dd)
get Calendar
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.valueOf(yyyy));
cal.set(Calendar.MONTH, Integer.valueOf(mm) - 1);
cal.set(Calendar.DATE, Integer.valueOf(dd));
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
...
CalendargetCalendar(TimeZone timeZone, Locale locale)
get Calendar
Calendar cal;
if (timeZone == null) {
    if (locale == null) {
        cal = Calendar.getInstance();
    } else {
        cal = Calendar.getInstance(locale);
} else {
...