Java Hour Add addHour(java.util.Date d, int h)

Here you can find the source of addHour(java.util.Date d, int h)

Description

add Hour

License

Apache License

Declaration

public static Calendar addHour(java.util.Date d, int h) 

Method Source Code

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

import java.util.Calendar;

public class Main {
    public static Calendar addHour(java.util.Date d, int h) {
        if (d == null)
            return null;
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);/* w w w.  j  a v a2  s .c  o  m*/
        cal.add(Calendar.HOUR, h);
        return cal;
    }

    public static Calendar add(java.util.Date d, int day) {
        if (d == null)
            return null;
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        cal.add(Calendar.DATE, day);
        return cal;
    }
}

Related

  1. addHH(Date date, int i)
  2. addHour(Date baseDate, int hour, TimeZone timezone)
  3. addHour(Date date, boolean up)
  4. addHours(Date date, int hours)
  5. addHours(long date, int hours)