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

DatePicker Calendar: wrong year format when 4 digits are used (yyyy), e.g. 2010 --> 0010

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.7
    • 1.4.8, 1.5-M1
    • wicket-datetime
    • None

    Description

      I found that there is still a bug in Wicket 1.4.7 in case that the datePattern is "dd/MM/yyyy".

      For example, if you use the DatePicker and select a date such as
      23/02/2010 from the calendar GUI, the date selected in the DateTextField is "23/02/0010".

      This is the example Java code:

      // define the date text field for the data decorrenza
      DateTextField dataDecorrenzaDaTextField = new DateTextField("dataDecorrenzaDa",
      new PropertyModel(this.accordo, "dataDecorrenzaDa"),
      new PatternDateConverter("dd/MM/yyyy", true)
      );

      // add the graphical calendar date picker
      dataDecorrenzaDaTextField.add(new DatePicker() {

      @Override
      protected boolean enableMonthYearSelection()

      { // enable month/year selection return true; }

      // end enableMonthYearSelection

      } // end DatePicker

      );

      I found that the bug is still in the "wicket-date.js", line 137.

      The wrong code is:

      if(datePattern.match(/yy+/)) year = Wicket.DateTime.padDateFragment(year % 100);

      This line also makes the module 100 on the year, when the year pattern is "yyyy".

      The fixed code is:

      if(datePattern.match(/yyyy+/)) {
      year = year;
      } else if(datePattern.match(/yy+/)) year = Wicket.DateTime.padDateFragment(year % 100);

      Attachments

        1. wicket-2767.patch
          1.0 kB
          Jonas

        Issue Links

          Activity

            People

              ivaynberg Igor Vaynberg
              pino_otto Giovanni
              Votes:
              5 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 5m
                  5m
                  Remaining:
                  Remaining Estimate - 5m
                  5m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified