Here you can find the source of addTimeInterval(Date origin, int value, int unit)
public static Date addTimeInterval(Date origin, int value, int unit)
//package com.java2s; /* /* w w w . j a v a 2s. c o m*/ * SWRVE CONFIDENTIAL * * (c) Copyright 2010-2014 Swrve New Media, Inc. and its licensors. * All Rights Reserved. * * NOTICE: All information contained herein is and remains the property of Swrve * New Media, Inc or its licensors. The intellectual property and technical * concepts contained herein are proprietary to Swrve New Media, Inc. or its * licensors and are protected by trade secret and/or copyright law. * Dissemination of this information or reproduction of this material is * strictly forbidden unless prior written permission is obtained from Swrve. */ import java.util.Calendar; import java.util.Date; public class Main { public static Date addTimeInterval(Date origin, int value, int unit) { Calendar cal = Calendar.getInstance(); cal.setTime(origin); cal.add(unit, value); return cal.getTime(); } }