Java Minute Add addMinutes(Date date, int minutes)

Here you can find the source of addMinutes(Date date, int minutes)

Description

add Minutes

License

LGPL

Declaration

public static Date addMinutes(Date date, int minutes) 

Method Source Code

//package com.java2s;
/*/*w w  w. jav  a 2  s .c om*/
* Distributable under LGPL v3 license.
* See terms of license at https://github.com/Yunfeng/schotel/blob/master/LICENSE
*/

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

public class Main {
    public static Date addMinutes(Date date, int minutes) {
        Calendar c = Calendar.getInstance();
        c.clear();
        c.setTime(date);
        c.add(Calendar.MINUTE, minutes);
        return c.getTime();
    }

    public static Date add(Date date, int x) {
        return addDays(date, x);
    }

    public static Date addDays(Date date, int x) {
        Calendar c = Calendar.getInstance();
        c.clear();
        c.setTime(date);
        c.add(Calendar.DATE, x);
        return c.getTime();
    }
}

Related

  1. addMinutes(Date in, int minutes)
  2. addMinutes(Date t, int minutes)
  3. addMinutes(java.util.Date date, long... minutes)
  4. addMinutesToDate(Date initialDateInMillis, Integer minutesToAdd)