Java Date Before getDateBeforeHours(Date date, int hours)

Here you can find the source of getDateBeforeHours(Date date, int hours)

Description

get Date Before Hours

License

Open Source License

Declaration

public static Date getDateBeforeHours(Date date, int hours) 

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 getDateBeforeHours(Date date, int hours) {
        return getDateAfterHours(date, 0 - hours);
    }/*from  www .java2s .  co  m*/

    public static Date getDateAfterHours(Date date, int hours) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.MINUTE, hours * 60);
        return c.getTime();
    }

    public static long getTime(Date date) {
        return date.getTime();
    }
}

Related

  1. getDateBefore(Date d, int day)
  2. getDateBefore(Date date, int days)
  3. getDateBefore(int offsetDay, String strFormat)
  4. getDateBefore(int year, int month, int day)
  5. getDateBefore(String d, int day)
  6. getDateBeforeNextMonth(Date date, Integer month, Integer day)
  7. getDateBeforeOrAfter(int iDate)
  8. getDateBeforeOrAfterV2(int idx)
  9. getDateBeforeSomeMinutes(int minute, long timestamp)