Java Date add Minute

Description

Java Date add Minute

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

public class Main {
  public static void main(String[] argv) {
    Date startDate = new Date();
    int addnos = 42;
    System.out.println(addMinute(startDate, addnos));
  }//from w  ww .ja  va  2  s . c o  m

  public static Date addMinute(Date startDate, int addnos) {
    Calendar cc = Calendar.getInstance();
    if (startDate != null) {
      cc.setTime(startDate);
      cc.add(Calendar.MINUTE, addnos);
      return cc.getTime();
    } else {
      return null;
    }
  }
}



PreviousNext

Related