List of utility methods to do Date Add
String | addDate(String date1, String addpart, int num) add Date return addTime(date1, addpart, num).substring(0, 10);
|
java.util.Date | addDate(String dt, long day) add Date if (dt == null) { throw new IllegalArgumentException("dt can not be null"); int len = dt.length(); if (!(len == 8 || len == 14)) { throw new IllegalArgumentException("dt length must be 8 or 14 (yyyyMMdd or yyyyMMddHHmmss)"); if (len == 8) { ... |
Date | addDateByDays(int days) add Date By Days return addDateByDays(getCurrentDate(), days);
|
Date | addDateDay(int day) add Date Day Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, day);
return calendar.getTime();
|
void | addDateParam(String dtstr, boolean start, List Adds a date parameter (start, end) as filter to the SQL where clause if (dtstr != null && isValidDate(dtstr)) { where.add("c.loginTime " + (start ? ">= '" : "<= '") + dtstr.substring(0, 4) + "-" + dtstr.substring(4, 6) + "-" + dtstr.substring(6) + " 00:00:00.000'"); |
Date | addDates(Date startDate, int days) add Dates Calendar cc = Calendar.getInstance(); if (startDate != null) { cc.setTime(startDate); cc.add(Calendar.DATE, days); return cc.getTime(); } else { return null; |
Date | addDay(Date date, int days) add Day Calendar cale = Calendar.getInstance();
cale.setTime(date);
cale.add(Calendar.DAY_OF_YEAR, days);
return cale.getTime();
|
Date | addDays(Date date1, long days) add Days return addSeconds(date1, days * ONE_DAY_SECONDS);
|
Date | addDays(Date dateToAdd, int numberOfDay) Add given number of days to a date. if (dateToAdd == null) { throw new IllegalArgumentException("Date can't be null!"); Calendar tempCal = Calendar.getInstance(); tempCal.setTime(dateToAdd); tempCal.add(Calendar.DATE, numberOfDay); return tempCal.getTime(); |
Date | addDays(Date target, int days) add Days long msPerDay = 1000 * 60 * 60 * 24; long msTarget = target.getTime(); long msSum = msTarget + (msPerDay * days); Date result = new Date(); result.setTime(msSum); return result; |