substituteDate function doesn't respect date pattern
----------------------------------------------------

                 Key: WICKET-2427
                 URL: https://issues.apache.org/jira/browse/WICKET-2427
             Project: Wicket
          Issue Type: Bug
          Components: wicket-datetime
    Affects Versions: 1.3.7
            Reporter: Reinout van Schouwen


The function Wicket.DateTime.substituteDate in wicket-date.js fails to 
correctly format dates.

Example: create a datetextfield like this
DateTextField birthDate = DateTextField.forDateStyle("birthdateFromAndTo", 
"M-");
and add a DatePicker to it:
birthDate.add(new DatePicker());
The datetextfield will only validate when the input matches 'd-MMM-yyyy' (for 
my locale, at least) as can be verified by executing birthDate.getTextFormat(). 
This translates to '17-augustus-2009' for today's date.

However, when a date is selected in the datepicker, it puts '17-8-2009' in the 
DateTextField. The reason is, I believe, that subsituteDate() assumes that all 
fields in the pattern are numbers. Instead, it should execute a proper date 
formatting. The function either should call the Wicket side to format the input 
date, or it should do it in javascript. On 
http://www.timdown.co.uk/code/simpledateformat.js I found an Apache licensed 
piece of javascript code that should do the work (it misses l10n though).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to