Link to home
Start Free TrialLog in
Avatar of ncsvietnam
ncsvietnam

asked on

Problem when convert string to date (invalid day of Feb)

Hi experts!

I met a problem when convert a string to date. Pls help, many thanks!
When input string represents a date with February month, invalid day of month (29 or 30, 31,..), it's automatically converted to March and day of month is (invalid input day of month - 28 (or 29)).
For example, input string "31/2/2009" will be converted to "3/3/2009"
SimpleDateFormat ts= new SimpleDateFormat("dd/MM/yyyy");
ava.sql.Date retDate = new java.sql.Date(ts.parse(inpCell.getContents()).getTime());

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial