Java Time Add addTime(Date source, int hours, int minutes, int second)

Here you can find the source of addTime(Date source, int hours, int minutes, int second)

Description

add Time

License

Apache License

Declaration

public static Date addTime(Date source, int hours, int minutes, int second) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {

    public static Date addTime(Date source, int hours, int minutes, int second) {
        if (source == null) {
            return null;
        }/*from w  w w .ja  va 2 s. c  om*/

        Calendar cal = Calendar.getInstance();
        cal.setTime(source);
        cal.add(Calendar.HOUR_OF_DAY, hours);
        cal.add(Calendar.MINUTE, minutes);
        cal.add(Calendar.SECOND, second);
        return cal.getTime();
    }
}

Related

  1. addTime(Date date, Date addTime)
  2. addTime(Date date, int field, int value)
  3. addTime(Date date, int field, int value)
  4. addTime(Date date, int mode, int amount)
  5. addTime(Date date, String time)
  6. addTimeByDate(int dateNum, Date date)
  7. addTimeIntervals(Date date, int type, int num)