Here you can find the source of postpone(final Calendar calendar, final int measureUnit, final int amount)
public static Date postpone(final Calendar calendar, final int measureUnit, final int amount)
//package com.java2s; //License from project: LGPL import java.util.*; public class Main { /**/*from w w w . j a v a2s. c om*/ * Milliseconds=14 * */ public static final int MILLISECOND = Calendar.MILLISECOND; /** * Seconds=13 * */ public static final int SECOND = Calendar.SECOND; /** * Minute=12 * */ public static final int MINUTE = Calendar.MINUTE; /** * Hour=11 * */ public static final int HOUR = Calendar.HOUR_OF_DAY; /** * Day=5 * */ public static final int DAY = Calendar.DAY_OF_MONTH; /** * MONTH=2 * */ public static final int MONTH = Calendar.MONTH; /** * Year=1 * */ public static final int YEAR = Calendar.YEAR; public static Date postpone(final Date date, final int measureUnit, final int amount) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return postpone(calendar, measureUnit, amount); } public static Date postpone(final Calendar calendar, final int measureUnit, final int amount) { switch (measureUnit) { case MILLISECOND: calendar.add(MILLISECOND, amount); break; case SECOND: calendar.add(SECOND, amount); break; case MINUTE: calendar.add(MINUTE, amount); break; case HOUR: calendar.add(HOUR, amount); break; case DAY: calendar.add(DAY, amount); break; case MONTH: calendar.add(MONTH, amount); break; case YEAR: calendar.add(YEAR, amount); break; } return calendar.getTime(); } }