Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
5.0-alpha
-
None
Description
When I run "mvn clean test", I got the following error:
[INFO] Results: [INFO] [ERROR] Failures: [ERROR] DateFormatTest.testStringToMillis:200 expected:<1669824000000> but was:<1669852800000> [ERROR] DateFormatTest.testStringToMillisSupplement:220 expected:<1669824000000> but was:<1669852800000>
When look into the "DateFormatTest.testStringToMillis", it has no timezone specified when converting a Date time to epoch time. In the DateFormat.getDateFormat(), it uses the default timezone:
public static FastDateFormat getDateFormat(String datePattern) { FastDateFormat r = formatMap.get(datePattern); if (r == null) { r = FastDateFormat.getInstance(datePattern, TimeZone.getDefault()); formatMap.put(datePattern, r); } return r; }
The function and test case shouldn't rely on user's default timezone. Which caused it may fail on another timezone.