I've noticed a change in behaviour for calculating 3 months ago when using v12.0p_2019-01-20/PowerEdition Deployment (built 2019-01-20). Please can you let me know if this is a bug or if my understanding is wrong.
Our code is: Date aDate = DateUtil.getAbsoluteDate(new RelativeDate("-3m"));
Previously, this would result in a date that was 3 months in the past from the current date/time e.g. if it's currently 09:34:29 on 11 April 2019 then aDate's value would be Fri Jan 11 09:34:29 GMT+000 2019. However, aDate is now calculated to be Fri Jan 11 12:00:00 GMT+000 2019.
From the Javadoc for RelativeDate, a lower case timeunit should be an exact offset, so if the timeunit is day or greater I'd expect the time would not be changed. This is the case for days and years, but no longer for months.
Some test results from creating aDate, via Date aDate = DateUtil.getAbsoluteDate(new RelativeDate("-3m")); varying the timeunit. The format of the results is timeunit followed by aDate.toString()
-3M Tue Jan 01 12:00:00 GMT+000 2019
-3m Fri Jan 11 12:00:00 GMT+000 2019
-1D Wed Apr 10 00:00:00 GMT+100 2019
-1d Wed Apr 10 09:34:29 GMT+100 2019
-2y Tue Apr 11 09:34:29 GMT+100 2017
-2Y Sun Jan 01 00:00:00 GMT+000 2017
Thank you.
Our code is: Date aDate = DateUtil.getAbsoluteDate(new RelativeDate("-3m"));
Previously, this would result in a date that was 3 months in the past from the current date/time e.g. if it's currently 09:34:29 on 11 April 2019 then aDate's value would be Fri Jan 11 09:34:29 GMT+000 2019. However, aDate is now calculated to be Fri Jan 11 12:00:00 GMT+000 2019.
From the Javadoc for RelativeDate, a lower case timeunit should be an exact offset, so if the timeunit is day or greater I'd expect the time would not be changed. This is the case for days and years, but no longer for months.
Some test results from creating aDate, via Date aDate = DateUtil.getAbsoluteDate(new RelativeDate("-3m")); varying the timeunit. The format of the results is timeunit followed by aDate.toString()
-3M Tue Jan 01 12:00:00 GMT+000 2019
-3m Fri Jan 11 12:00:00 GMT+000 2019
-1D Wed Apr 10 00:00:00 GMT+100 2019
-1d Wed Apr 10 09:34:29 GMT+100 2019
-2y Tue Apr 11 09:34:29 GMT+100 2017
-2Y Sun Jan 01 00:00:00 GMT+000 2017
Thank you.
Comment