Do not use
java.util.Calendar.getInstance().Time Instead use gw.api.util.DateUtil.CurrentDate (or) java.util.Date.CurrentDate INCORRECT USAGE : var currentDate = new java.util.Date() (or) var currentDate1 = java.util.Calendar.getInstance().Time CORRECT USAGE : var currentDate = java.util.Date.CurrentDate // Note that “new” is not used here var currentDate = gw.api.util.DateUtil.currentDate()
java.util.Date is a Java in-built class that implements the Comparable interface which is NOT thread safe. More importantly, java.util.Date returns the JVM date, while java.util.Date.CurrentDate returns the test system clock date. The use of java.util.Date can cause difficult to debug issues in accelerated (changing the system clock ) environments. If the code uses, java.utilDate, then It would be very difficult to properly test the functional and integration code because the date/time retrieved in the code (from the java.util.Date) would not reflect the test system clock that was advanced into the future from the current date.