Android Date Add addTimeInterval(Date origin, int value, int unit)

Here you can find the source of addTimeInterval(Date origin, int value, int unit)

Description

add Time Interval

License

Open Source License

Declaration

public static Date addTimeInterval(Date origin, int value, int unit) 

Method Source Code

//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();
    }
}

Related

  1. addYears(Date date, int amount)
  2. addYears(Date date, int amount)
  3. dateByAddHoursAndMinutes(Date date, int hours, int minutes)
  4. getDateAdd(Date date, int amount)
  5. addDaysToDate(Date date, int days)