Here you can find the source of addTime(Date date, int field, int value)
public static Date addTime(Date date, int field, int value)
//package com.java2s; //License from project: LGPL import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import static java.util.Calendar.*; public class Main { public static Date addTime(Date date, int field, int value) { Calendar cal = cal(date); cal.add(field, value);/*from w w w . j a v a 2 s. c om*/ return cal.getTime(); } public static Calendar cal(Date date) { if (date == null) { return null; } else { return cal(date.getTime()); } } public static Calendar cal(Date date, Integer hour, Integer minutes) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(HOUR_OF_DAY, hour); calendar.set(MINUTE, minutes); calendar.set(SECOND, 0); calendar.set(MILLISECOND, 0); return calendar; } public static Calendar cal(long millis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(millis); return calendar; } public static Calendar cal(int year, int month, int date) { return new GregorianCalendar(year, month, date); } public static Calendar cal(int year, int month, int date, int hour, int minutes) { return new GregorianCalendar(year, month, date, hour, minutes); } }