Java Hour Add addHour(Date date, boolean up)

Here you can find the source of addHour(Date date, boolean up)

Description

add Hour

License

Open Source License

Declaration

public static Date addHour(Date date, boolean up) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Date addHour(Date date, boolean up) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);//from   ww w .ja va 2s .c  om
        if (up) {
            cal.add(Calendar.HOUR_OF_DAY, 1);
        } else {
            cal.add(Calendar.HOUR_OF_DAY, -1);
        }

        return cal.getTime();
    }
}

Related

  1. addHH(Date date, int i)
  2. addHour(Date baseDate, int hour, TimeZone timezone)
  3. addHour(java.util.Date d, int h)
  4. addHours(Date date, int hours)
  5. addHours(long date, int hours)