Here you can find the source of getTimestampMinusDays(Integer days)
Parameter | Description |
---|---|
days | a parameter |
public static Timestamp getTimestampMinusDays(Integer days)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; public class Main { /**//from ww w .j a v a 2s. c o m * Return a sql timestamp minus for the current day minus the specified days * * @param days * @return */ public static Timestamp getTimestampMinusDays(Integer days) { Date d = getDateMinusDays(days); if (d != null) { return new Timestamp(d.getTime()); } return null; } /** * Return the current date minus the number of specified days * * @param days * @return */ public static Date getDateMinusDays(Integer days) { if (days != null) { int total = days > 0 ? days * -1 : days; Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, total); return cal.getTime(); } return null; } }