Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2427

substituteDate function doesn't respect date pattern

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.7
    • None
    • wicket-datetime
    • None

    Description

      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).

      Attachments

        1. wicket-2427-wicket-datetime.patch
          31 kB
          Igor Vaynberg

        Issue Links

          Activity

            People

              ivaynberg Igor Vaynberg
              reinouts Reinout van Schouwen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: