Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.1.14
-
None
-
None
-
software platform
Description
On JSF page, we use <t:inputDate> to display Date/Time field on UI. And when user type "leading empty space" for date field(for example, user try to type "1" for Date on UI, but accidentally he type " 1 ", and then click on submit. Because of space, it will throw error.
I trace the src code and find out the problem is on org.apache.myfaces.custom.date.AbstractHtmlInputDate, when it parse, it throw the error in the following:
public Date parse() throws ParseException{
.....
try {
...
tempCalendar.set(Calendar.DAY_OF_MONTH,Integer.parseInt(day));
...
} catch (NumberFormatException e)
}
As you can see, day is " 1 " in my use case, and it will throw the error. So the best solution is we need to do in the following way:
tempCalendar.set(Calendar.DAY_OF_MONTH,Integer.parseInt(day.trim()));
Same issue happen on hours/minutes/second