Here you can find the source of addDate(java.util.Date date, int day)
Parameter | Description |
---|---|
date | a parameter |
day | a parameter |
public static java.util.Date addDate(java.util.Date date, int day)
//package com.java2s; //License from project: Open Source License public class Main { public static java.util.Date addDate(java.util.Date date, int day) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTimeInMillis(getMillis(date) + ((long) day) * 24 * 3600 * 1000); return c.getTime(); }/*w w w . ja va2s . com*/ public static long getMillis(java.util.Date date) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(date); return c.getTimeInMillis(); } public static String getTime(java.util.Date date) { return format(date, "HH:mm:ss"); } public static String format(java.util.Date date, String format) { String result = ""; try { if (date != null) { java.text.DateFormat df = new java.text.SimpleDateFormat(format); result = df.format(date); } } catch (Exception e) { } return result; } }