Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4851

Datebox fails with default DateFormat from Java 11.0.2+

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 9.6.0
    • Freshly, 9.6.0
    • Components
    • Security Level: Jimmy

      Steps to Reproduce

      run current 9.6.0 FL with a datebox:

       

      <zk><datebox/></zk>
      

       

       

      Current Result

      Datebox receives an unusable format: "Apr 2, 1"

      Received from server-side (with a browser request for "Accept-Language: en-US,en;q=0.9,fr;q=0.8"

      receieved: ['zul.db.Datebox','mCCU0*',{format:'MMM d, y'* ...

      Since default format uses a 1 digit year, selecting a date in 2021 in the datebox popup will actually set a date of 2001

       

      no value, open current day:

       

      Selecting a value in current month, parsed value in 2001:

      Expected Result

      Default return a usable format

      Debug Information

      behavior introduced in https://tracker.zkoss.org/browse/ZK-4745

      Before this feature implementation, the client widget would still receive the format string with a single y digit, but would ignore it and treat "y" as "yy" for the purpose of displaying the date.

      Not sure if that was a bug or an existing workaround.

       

      JVM 11+ uses the unicode standard for date / time formats.

      See here:

      https://www.unicode.org/cldr/cldr-aux/charts/33/by_type/date_&_time.gregorian.html#14164b88b71705de

      (warning big page, open in FF if fails in chrome) 

       

      DateFormat.DEFAULT is used in datebox:

      https://github.com/zkoss/zk/blob/master/zul/src/org/zkoss/zul/Datebox.java#L239

      It resolves to DateFormat.MEDIUM

      https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#DEFAULT

       

      Workaround

      according to java9 release note: https://www.oracle.com/java/technologies/javase/9-relnotes.html#JDK-8008577

      setting java.locale.providers to a value with COMPAT ahead of CLDR.

      -Djava.locale.providers=COMPAT,CLDR,SPI

      The property "java.locale.providers" is only read at the Java runtime startup, so the later call to System.setProperty() won't have effect. (See LocaleServiceProvider API ).

      or just specify format: 

      <datebox format="yyyy/MM/dd"/>

       

        1. image-2021-04-02-12-13-40-000.png
          8 kB
          MDuchemin
        2. image-2021-04-02-12-14-13-891.png
          9 kB
          MDuchemin
        3. image-2021-04-02-12-32-36-593.png
          2 kB
          MDuchemin
        4. image-2021-04-02-12-32-39-655.png
          2 kB
          MDuchemin

            Leon03 Leon03
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: