List of utility methods to do Calendar Create
Calendar | createDate(TimeZone timeZone, int year, int month, int day) Creates a Calendar instance for the given year, month (1-based), and day (1-based) in the given time zone Calendar date = Calendar.getInstance(timeZone);
date.clear();
date.set(year, month - 1, day);
return date;
|
Calendar | createDate(TimeZone timeZone, int year, int month, int day, int hour, int minute, int second) Creates a Calendar instance for the given year, month (1-based), day (1-based), hour, minute and second in the given time zone Calendar date = Calendar.getInstance(timeZone);
date.set(year, month - 1, day, hour, minute, second);
date.set(Calendar.MILLISECOND, 0);
return date;
|
Calendar | createDate(int year, int month, int day) Creates a Calendar instance for the given year, month (1-based), and day (1-based) in the default time zone Calendar date = Calendar.getInstance();
date.clear();
date.set(year, month - 1, day);
return date;
|
Calendar | createDate(int year, int month, int day, int hour, int minute, int second) Creates a Calendar instance for the given year, month (1-based), day (1-based), hour, minute and second in the default time zone Calendar date = Calendar.getInstance();
date.set(year, month - 1, day, hour, minute, second);
date.set(Calendar.MILLISECOND, 0);
return date;
|
Calendar | getCalendar() get Calendar setDefaultTimeZoneToVietnam(); Calendar today = Calendar.getInstance(); today.setTime(new Date()); return today; |
Calendar | getCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute) get Calendar Calendar startRollingTime = Calendar.getInstance();
startRollingTime.set(Calendar.YEAR, year);
startRollingTime.set(Calendar.MONTH, month);
startRollingTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
startRollingTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
startRollingTime.set(Calendar.MINUTE, minute);
startRollingTime.set(Calendar.SECOND, 00);
return startRollingTime;
...
|
Date | getCurrentTime() get Current Time return getCalendar().getTime();
|
String | getDateWithFormat(int year, int month, int day) get Date With Format SimpleDateFormat dateFormat = new SimpleDateFormat( "EEEE, MMMM d, yyyy"); return dateFormat.format(new GregorianCalendar(year, (month - 1), day).getTime()); |
String | getDateWithShortFormat(int year, int month, int day) get Date With Short Format SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, MMM d, yyyy"); return dateFormat.format(new GregorianCalendar(year, (month - 1), day).getTime()); |
long | getMilliSeconds(int year, int month, int day, int hour, int minute) get Milli Seconds Calendar c = Calendar.getInstance(); c.setTime(new GregorianCalendar(year, (month - 1), day, hour, minute).getTime()); return c.getTimeInMillis(); |