Here you can find the source of add(Date date, int field, long amount)
Parameter | Description |
---|---|
date | the date |
field | the field |
amount | the amount |
public static Date add(Date date, int field, long amount)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { /**//from w ww .j a v a 2 s. c om * Adds the specified (signed) amount of time to the given time field, based * on the calendar's rules. * * @param date * the date * @param field * the field * @param amount * the amount * @return the date */ public static Date add(Date date, int field, long amount) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(field, (int) amount); return calendar.getTime(); } }