List of utility methods to do Date Add
Calendar | addDate(Date date, int field, int add) add Date Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(field, add);
return calendar;
|
String | addDate(Date date, int k) add Date java.util.Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, k);
return format(cal.getTime());
|
Date | addDate(Date date, int noOfDays) Add no of days to a given date, pass negative number if past or to substract date. Calendar c1 = Calendar.getInstance();
c1.setTime(date);
c1.add(Calendar.DATE, noOfDays);
return c1.getTime();
|
Date | addDate(Date date, int years, int months, int days) Calculates a date relative to the supplied date. Calendar calendar = Calendar.getInstance(); if (date != null) calendar.setTime(date); if (years != 0) calendar.add(Calendar.YEAR, years); if (months != 0) calendar.add(Calendar.MONTH, months); if (days != 0) ... |
Date | addDate(Date date, String unit, int quantity) add date if (unit.equalsIgnoreCase("Year")) { return addYear(date, quantity); if (unit.equalsIgnoreCase("Month")) { return addMonth(date, quantity); if (unit.equalsIgnoreCase("Week")) { return addWeek(date, quantity); ... |
String | addDate(int field, int amount) add Date int temp = 0; if (field == 1) { temp = Calendar.YEAR; if (field == 2) { temp = Calendar.MONTH; if (field == 3) { ... |
java.util.Date | addDate(java.util.Date date, int day) add Date java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(date); c.setTimeInMillis(c.getTimeInMillis() + (long) day * 24 * 3600 * 1000); return c.getTime(); |
Date | addDate(String date) add Date if (date == null) { return null; Date tempDate = parseDate("yyyy-MM-dd", date); String year = format(tempDate, "yyyy"); String month = format(tempDate, "MM"); String day = format(tempDate, "dd"); GregorianCalendar calendar = new GregorianCalendar(Integer.parseInt(year), Integer.parseInt(month) - 1, ... |
Date | addDate(String date, int amount) add Date if (date == null || "".equals(date.trim())) { return null; Calendar calendar = Calendar.getInstance(); calendar.setTime(getDate(date)); calendar.add(Calendar.DATE, amount); return calendar.getTime(); |
String | addDate(String date, String type, int into) add Date String Sdate = ""; try { GregorianCalendar grc = new GregorianCalendar(); grc.setTime(new Date(date)); if (type.equals("D")) { grc.add(GregorianCalendar.DATE, into); } else if (type.equals("M")) { grc.add(GregorianCalendar.MONTH, into); ... |