Java Time Add addTimeIntervals(Date date, int type, int num)

Here you can find the source of addTimeIntervals(Date date, int type, int num)

Description

add Time Intervals

License

Open Source License

Declaration

private static Date addTimeIntervals(Date date, int type, int num) 

Method Source Code

//package com.java2s;
/*/*from w  ww  . j  a  v a 2 s. c o m*/
 * Copyright (c) 1999-2002 Erry Network Technology, Inc. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of Erry
 * Network Technology, Inc. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Erry.
 *
 * ERRY MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. ERRY SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 *
 * $Archive: /src/work/com/erry/its/model/tools/DateUtil.java $ $Revision: 1.2 $
 */

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static Date addTimeIntervals(Date date, int type, int num) {
        if (date == null)
            throw new IllegalArgumentException();
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(type, num);
        return c.getTime();
    }
}

Related

  1. addTime(Date date, int field, int value)
  2. addTime(Date date, int mode, int amount)
  3. addTime(Date date, String time)
  4. addTime(Date source, int hours, int minutes, int second)
  5. addTimeByDate(int dateNum, Date date)