Wednesday, February 29, 2012

ADF 11G : How To Get The Date After N Days ?

    static final long MILI_SECONDS_PER_DAY = 86400000;

    public static Date dateAfterNDays( Date startDate, int nDays)

    {

       if (startDate == null)

           startDate = new Date(Date.getCurrentDate());  // assume today

       Timestamp ts = startDate.timestampValue();

       long nextDatesSecs = ts.getTime() + (MILI_SECONDS_PER_DAY * nDays);

       return new Date( new Timestamp(nextDatesSecs));

    }