Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361767 - TypeCastException is not thrown for some invalid assignments of strings to dates.
Summary: TypeCastException is not thrown for some invalid assignments of strings to da...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-23 23:23 EDT by Tom B CLA
Modified: 2017-02-23 14:20 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom B CLA 2011-10-23 23:23:28 EDT
Build Identifier: EGL Development Tools (EDT)	0.7.0.v201110232102

I have noticed that in some cases the TypeCastException is not thrown when I assign a string to a date.

For example, i can do this:
invalidDate date = "40-40-2011";

No exception is thrown, even though the date is invalid

is this because the string is in the correct format (xx-xx-xxxx) even though it does not represent a valid date?

I've noticed that these don't throw exceptions either

invalidDate date = "1 3 4"; date is printed out as 0004-01-02
invalidDate date = "1&3&4";
invalidDate date = "12-34-5678";
invalidDate date = "12345678";
invalidDate date = "123456789";


Reproducible: Always

Steps to Reproduce:
1. Generate EDate009.egl for Java testing. The file can be found in
org.eclipse.edt.eunit.test/api.eglx_lang

2. Run the generated java program. The output shows that the expected error is not thrown when assigning dates from some strings that represent invalid dates
Comment 1 Jeff Douglas CLA 2011-10-25 08:45:32 EDT
fixed
Comment 2 Tom B CLA 2011-10-31 01:58:47 EDT
This still has not been fixed:

invalidDate date = "1&3&4";

everything else seems ok
Comment 3 Jeff Douglas CLA 2011-10-31 08:28:14 EDT
It is my opinion that the testcase is wrong. Any character can be used as the separator character, and in this case you are using &. This means that the date being accepted is valid as 01/03/0004.
Comment 4 Lisa Lasher CLA 2011-11-11 18:09:13 EST
closing the defect