Here you can find the source of createFutureDate(int days, int months)
Parameter | Description |
---|---|
days | number of days to be added to the current date |
months | number of months to be added to the current date |
public static String createFutureDate(int days, int months)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**/*from w w w .ja v a 2 s . co m*/ * Creates a new date/time string presented in the SIP2 format * "yyyyMMdd HHmmss" by adding the given number of days and months * to the current date. This method is usefull when setting an * expiration date to a hold. * * @param days number of days to be added to the current date * @param months number of months to be added to the current date * @return current date plus the given number of days and months in the * SIP2 format "yyyyMMdd HHmmss" */ public static String createFutureDate(int days, int months) { Calendar date = Calendar.getInstance(); date.setTime(new Date()); date.add(Calendar.DATE, days); date.add(Calendar.MONTH, months); return toSipDateTime(date.getTime()); } /** * Converts the given date to a SIP2 formatted date/time string. The SIP2 * format is "yyyyMMdd HHmmss". * * @param date date object to be converted * @return SIP2 formatted date/time string */ public static String toSipDateTime(Date date) { SimpleDateFormat simpleDf = new SimpleDateFormat("yyyyMMdd HHmmss"); return simpleDf.format(date); } }