List of utility methods to do Date Adjust
java.util.Date | adjustDate(Date dtDate, int iYears, int iMonths, int iDays, int iHours, int iMinutes, int iSeconds) Adjusts the Date passed in by the appropriate amounts. if (dtDate == null) return null; Calendar cal = Calendar.getInstance(); Calendar calNew = Calendar.getInstance(); cal.setTime(dtDate); calNew.setTime(dtDate); calNew.set(cal.get(Calendar.YEAR) + iYears, cal.get(Calendar.MONTH) + iMonths, cal.get(Calendar.DAY_OF_MONTH) + iDays, cal.get(Calendar.HOUR_OF_DAY) + iHours, ... |
Date | adjustDays(Date startingDate, int deltaDays) Takes a Date and moves in the desired amount of days. Calendar cal = Calendar.getInstance();
cal.setTime(startingDate);
cal.add(Calendar.DATE, deltaDays);
return cal.getTime();
|
Date | adjustHour(Date dt, int hour) adjust Hour Calendar cal = Calendar.getInstance();
cal.setTime(dt);
cal.add(Calendar.HOUR, hour);
return cal.getTime();
|
Date | adjustHourAndMinute(Date n) adjust Hour And Minute if (n == null) n = new Date(); Calendar cal = Calendar.getInstance(); int hour = cal.get(Calendar.HOUR_OF_DAY); int minutes = cal.get(Calendar.MINUTE); cal.setTime(n); cal.set(Calendar.MINUTE, minutes); cal.set(Calendar.HOUR_OF_DAY, hour); ... |
Date | adjustTime(Date date, int hour, int minute, int second) adjust Time Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.HOUR, hour);
c.add(Calendar.MINUTE, minute);
c.add(Calendar.SECOND, second);
return c.getTime();
|
void | adjustToDayStartAndEnd(Date from, Date to) Set a period to day start and end. adjustToDayStart(from); adjustToDayEnd(to); |
Date | getAdjustDayResetTime(Date date, int adjustAmount) get Adjust Day Reset Time if (date == null) { return null; Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); ... |
Date | getAdjustedDate(Date original, int millisecondAdjustment) get Adjusted Date Date result = null; if (original != null) { Calendar cal = Calendar.getInstance(); cal.setTime(original); cal.add(Calendar.MILLISECOND, millisecondAdjustment); result = cal.getTime(); return result; ... |
Date | getTimeWithAdjustment(Date date, boolean carryover) get Time With Adjustment Calendar cal = Calendar.getInstance(); if (date != null) { cal.setTime(date); if (carryover) { cal.add(Calendar.DAY_OF_YEAR, 1); return cal.getTime(); ... |