[Neon] Change DateUtility.parse(String, String) not to parse dates leniently [message #1719468] |
Fri, 08 January 2016 08:51 |
Matthias Otterbach Messages: 55 Registered: August 2015 Location: Munich |
Member |
|
|
Currently the org.eclipse.scout.rt.platform.util.date.DateUtility.parse(String, String) method does not change the default lenient setting of SimpleDateFormat. The default setting of SimpleDateFormat however is lenient = true.
With this setting the parse method returns a best guess which date corresponds to the given String. Only if it is not possible to guess the date an exception is thrown.
For example the following parse operations result in the commented dates:
DateUtility.parse("942.790.2016", "dd.MM.yyyy"); // Sat Apr 29 00:00:00 CEST 2084
DateUtility.parse("13.13.2015", "dd.MM.yyyy"); // Wed Jan 13 00:00:00 CET 2016
DateUtility.parse("05.13.2015", "dd.MM.yyyy"); // Tue Jan 05 00:00:00 CET 2016
DateUtility.parse("29.02.2015", "dd.MM.yyyy"); // Sun Mar 01 00:00:00 CET 2015
DateUtility.parse("29.02.2016", "dd.MM.yyyy"); // Mon Feb 29 00:00:00 CET 2016
In my opinion this must not be the case (only the last line returns the date I would expect). I would propose to change this method to use lenient = false for future Scout releases. DateUtilityTest does not fail after this change.
Would you agree? Are there any other opinions?
[Updated on: Tue, 12 January 2016 05:23] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03678 seconds