Java SQL Date Get getDateBefore(Date date, Integer before)

Here you can find the source of getDateBefore(Date date, Integer before)

Description

get Date Before

License

Apache License

Declaration

public static Date getDateBefore(Date date, Integer before) 

Method Source Code


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

import java.sql.Date;

public class Main {
    public static Date getDateBefore(Date date, Integer before) {
        if (before == 0) {
            return new Date(date.getTime());
        }/*from   www .  j av  a  2  s .co m*/
        Date d = new Date(date.getTime());
        for (int i = 0; i < before; i++) {
            d.setTime(d.getTime() - 86400000);
        }
        return d;
    }
}

Related

  1. getDate(Timestamp timestamp)
  2. getDate(Timestamp ts)
  3. getDateAddMonth(java.sql.Date date, int months)
  4. getDateAsLong(ResultSet rset, Enum field)
  5. getDateAsLong(Timestamp date)
  6. getDateBeforTwelveMonth()
  7. getDateByNum(String dateNum)
  8. getDateByYearAndMonth(int year, int month)
  9. getDateDiscrepancy(String startDate, String endDate)