Get date of last number of day - Java java.util

Java examples for java.util:Day

Description

Get date of last number of day

Demo Code


//package com.java2s;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {

    public static Date getLastBefore(Integer days) {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.set(GregorianCalendar.HOUR_OF_DAY, 0);
        calendar.set(GregorianCalendar.MINUTE, 0);
        calendar.set(GregorianCalendar.SECOND, 0);

        calendar.add(GregorianCalendar.DATE, -4);
        Date begin = calendar.getTime();

        return begin;
    }/*from  w  w  w  . j  ava  2  s.co  m*/
}

Related Tutorials