Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » [Neon] Change DateUtility.parse(String, String) not to parse dates leniently
[Neon] Change DateUtility.parse(String, String) not to parse dates leniently [message #1719468] Fri, 08 January 2016 08:51 Go to next message
Matthias OtterbachFriend
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

Re: Change DateUtility.parse(String, String) not to parse dates leniently [message #1719787 is a reply to message #1719468] Tue, 12 January 2016 05:23 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
If there are no objections, I will include this change for the Neon release.

Proposed change: https://git.eclipse.org/r/#/c/64094

[Updated on: Tue, 12 January 2016 05:30]

Report message to a moderator

Re: Change DateUtility.parse(String, String) not to parse dates leniently [message #1719806 is a reply to message #1719787] Tue, 12 January 2016 08:30 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Thank you for bringing this topic here. I never encountered the problem and I agree with you: if nobody complains, it means that it is OK (and anyone is free to continue the discussion).

I have written some comments on Gerrit.
Previous Topic:[Mars] [HowTO] Row-Level Granting
Next Topic:Problem with the @Replace annotation
Goto Forum:
  


Current Time: Tue Apr 23 07:32:25 GMT 2024

Powered by FUDForum. Page generated in 0.03678 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top