Details
-
Type:
Sub-task
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Ubuntu Gutsy Gibbon
-
Testcase included:yes
-
Number of attachments :
Description
import org.joda.time.DateTime import static org.joda.time.DateTimeZone class EWUtils { static DateTime nowUTC() { return new DateTime(UTC) } } //Inside a test case import static EWUtils.nowUTC ... DateTime baseDate = nowUTC() println "${baseDate.minusWeeks(1)} ${baseDate.minusWeeks(1).millis}" println "${nowUTC().minusWeeks(1)} ${nowUTC().minusWeeks(1).millis}" // The output 2008-04-16T18:40:09.698Z 1208371209698 2008-04-16T18:40:09.709Z 1208976009709
The second println statement demonstrates the bug. The epoch time is approximately equal to the current time instead of being a week old as in the first example.
The bug only manifests when nowUTC() belongs to another class - if I move it into the same class as the test it's OK
the output is not very clear, but I thin I get it now. 1208371209698 is the time in millis for 2008-04-16T18:40:09.698Z, which is correct. 1208976009709 is not the same date, it is a date one week (and a few millis) in the future.
Only... I have problems reproducing this issue. Which version of Groovy did you use? Can you give an example that uses no external lib?