Java Minute Add addMinutesToDate(Date initialDateInMillis, Integer minutesToAdd)

Here you can find the source of addMinutesToDate(Date initialDateInMillis, Integer minutesToAdd)

Description

add Minutes To Date

License

Open Source License

Declaration

public static Long addMinutesToDate(Date initialDateInMillis, Integer minutesToAdd) 

Method Source Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Long addMinutesToDate(Date initialDateInMillis, Integer minutesToAdd) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(initialDateInMillis);
        cal.add(Calendar.MINUTE, minutesToAdd);
        return cal.getTimeInMillis();
    }//  w w w  .j av  a 2s  .  c  o  m

    public static Long addMinutesToDate(Long initialDateInMillis, Integer minutesToAdd) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date(initialDateInMillis));
        cal.add(Calendar.MINUTE, minutesToAdd);
        return cal.getTimeInMillis();
    }
}

Related

  1. addMinutes(Date date, int minutes)
  2. addMinutes(Date in, int minutes)
  3. addMinutes(Date t, int minutes)
  4. addMinutes(java.util.Date date, long... minutes)
  5. addMinutesToDate(final Date d, final int minutes)