List of utility methods to do Day Add
String | add(int date, int days) add try { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); Calendar cd = Calendar.getInstance(); cd.setTime(format.parse(String.valueOf(date))); cd.add(Calendar.DAY_OF_YEAR, days); return format.format(cd.getTime()); } catch (ParseException e) { throw new RuntimeException(e); ... |
String | add(String date, int day) add SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); long d = df.parse(date).getTime(); long millis = d + ((long) day) * 24 * 3600 * 1000; return df.format(new Date(millis)); |
Date | addDate(Date d, long day) add Date long time = d.getTime(); day = day * 24 * 60 * 60 * 1000; time += day; return new Date(time); |
Date | addDate(Date date, int day) add Date Calendar calendar = Calendar.getInstance(); long millis = getMillis(date) + day * 24L * 3600L * 1000L; calendar.setTimeInMillis(millis); return calendar.getTime(); |
java.util.Date | addDate(java.util.Date date, int day) add Date java.util.Calendar c = java.util.Calendar.getInstance(); c.setTimeInMillis(getMillis(date) + ((long) day) * 24 * 3600 * 1000); return c.getTime(); |
String | addDate(String date, SimpleDateFormat format, int dayCnt) add Date Date oldDate = new Date(); long curTimeStamp = 0; try { oldDate = format.parse(date); } catch (ParseException e) { return date; curTimeStamp = oldDate.getTime(); ... |
Date | addDate(String str, int field, int dayNum) add Date Date date = null; SimpleDateFormat sdate = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar gc = new GregorianCalendar(); try { date = (Date) sdate.parse(str); gc.setTime(date); gc.add(field, dayNum); } catch (ParseException e) { ... |
Date | addDay(Date d, int amount) add Day return add(d, Calendar.DATE, amount);
|
Date | addDay(Date date, int day) add Day Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DAY_OF_MONTH, day);
return c.getTime();
|
Date | addDay(Date date, int day) add Day Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, day);
return cal.getTime();
|