Java Date Set setHours(Date date, int amount)

Here you can find the source of setHours(Date date, int amount)

Description

set Hours

License

Open Source License

Declaration

public static Date setHours(Date date, int amount) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static Date setHours(Date date, int amount) {
        return set(date, Calendar.HOUR_OF_DAY, amount);
    }/*from w  ww .  j a v a  2s.  com*/

    public static Date set(Date date, int calendarFiled, int amount) {
        if (null == date) {
            throw new IllegalArgumentException("The date must not be null");
        } else {

        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(calendarFiled, amount);
        return c.getTime();
    }
}

Related

  1. setDayStart(final Date date)
  2. setField(Date date, int field, int value)
  3. setHour(java.util.Date date, Integer hour)
  4. setHourMinuteSecondToZeroPlus24Hours(Date datetime)
  5. setHours(Date d, int hours)
  6. setMilliSecondsToDate(Date date, Integer milliSeconds)
  7. setMinDate(Date d)
  8. setMinSeconds(Date date)
  9. setMinute(Date date, int minute)