List of utility methods to do Date Add
Date | addDays(Date when, int amount) add Days return add(when, Calendar.DAY_OF_YEAR, amount);
|
Calendar | addDays(int count, Calendar timestamp) Adds or subtracts the corresponding time field, does not perform any alignment. timestamp.add(Calendar.DATE, count);
return timestamp;
|
Date | addDaysToCurrentDate(Integer dayIncrement) add Days To Current Date Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.DATE, dayIncrement);
return calendar.getTime();
|
Date | addInteger(Date date, int dateType, int amount) add Integer if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(dateType, amount); date = calendar.getTime(); return date; |
Date | addSeconds(Date date1, long secs) add Seconds return new Date(date1.getTime() + (secs * 1000)); |
String | dateAdd(Date date, int days) date Add SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); String toDate = dateFormat.format(new Date()); return dateAdd(toDate, days); |
Date | dateAdd(Date date, int days) Convenience method to add specified number of days to the given date Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.add(Calendar.DAY_OF_MONTH, days); return cal.getTime(); |
Date | dateAdd(Date date, int field, int amount) date Add Calendar calendar = Calendar.getInstance(); try { calendar.setTime(date); calendar.add(field, amount); return calendar.getTime(); } catch (Exception e) { System.out.println("DateAdd Exception :" + e); return null; ... |
Date | dateAdd(Date date, int type, int num) date Add Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(type, num);
return c.getTime();
|
Date | dateAdd(Date date, int val) date Add Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.DAY_OF_MONTH, val); date = calendar.getTime(); return date; |