List of utility methods to do Calendar Set
void | setTo2359(Calendar c) set To c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); c.set(Calendar.MILLISECOND, 999); |
void | setToDec31(Calendar c) set To Dec c.set(Calendar.MONTH, 11); c.set(Calendar.DAY_OF_MONTH, 31); setTo2359(c); |
void | modify(Calendar val, int field, boolean round) modify if (val.get(Calendar.YEAR) > 280000000) { throw new ArithmeticException( "Calendar value too large for accurate calculations"); if (field == Calendar.MILLISECOND) { return; Date date = val.getTime(); ... |
Calendar | prepareCalendar(int hourOfDay, int minute) prepare Calendar Calendar calNow = Calendar.getInstance();
Calendar calSet = (Calendar) calNow.clone();
calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
calSet.set(Calendar.MINUTE, minute);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);
if (calSet.compareTo(calNow) <= 0) {
calSet.add(Calendar.DATE, 1);
...
|
DateTime | toDateTime(Calendar calendar) to Date Time DateTime dateTime = new DateTime(); dateTime.set(calendar.get(Calendar.MINUTE), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.YEAR)); return dateTime; |
void | stripTime(Calendar cal) strip Time cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); |
void | setDate(Calendar cal, long date) set Date int year = (int) (date / 10000); int month = (int) ((date / 100) % 100); int day = (int) (date % 100); cal.set(year, month - 1, day); |
void | setTime(Calendar cal, long time) set Time int hour = (int) (time / 10000); int minute = (int) ((time / 100) % 100); int second = (int) (time % 100); cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); cal.set(Calendar.SECOND, second); |
Date | moveToDate(int field, int amount) move To Date Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(field, amount); return calendar.getTime(); |