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

DatePicker does not parse year with pattern dd.MM.yyyy correctly.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • wicket-datetime
    • None

    Description

      We use the date pattern dd.MM.yyyy, and when returning from the date picker (org.apache.wicket.extensions.yui.calendar.DatePicker) yields incorrect value in the date text field (org.apache.wicket.extensions.markup.html.form.DateTextField).

      For instance picking the date 19.04.2010 in the date picker, yields 19.04.10, which again becomes the java.util.Date 19.04.0010. We have found the source of the problem, and created a fix for this, but hopefully you can fix this in a later release, so we do not have to maintain a local patched version of wicket-datetime.

      I have included the patch here. However this code seems very intentional, so applying this patch may be breaking something else!?

      Thanks

      • Alf

      diff --git a/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js b/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js
      index 7f19c55..420f075 100644
      — a/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js
      +++ b/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js
      @@ -134,7 +134,7 @@ Wicket.DateTime.substituteDate = function(datePattern, date)

      { // optionally do some padding to match the pattern if(datePattern.match(/dd+/)) day = Wicket.DateTime.padDateFragment(day); if(datePattern.match(/MM+/)) month = Wicket.DateTime.padDateFragment(month); - if(datePattern.match(/yy+/)) year = Wicket.DateTime.padDateFragment(year % 100); + if(datePattern.match(/yy+/)) year = Wicket.DateTime.padDateFragment(year); // replace pattern with real values return datePattern.replace(/d+/, day).replace(/M+/, month).replace(/y+/, year); }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              stoyle Alf Støyle
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: