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

datebox formatting/parsing doesn't handle quoted characters correctly

XMLWordPrintable

      Steps to Reproduce

      display a datebox using the Portuguese locale in 'medium' or 'long' format

      <datebox locale="pt" format="medium" onCreate="self.setValue(new Date());" width="300px"/>
      <separator/>
      <datebox locale="pt" format="long" onCreate="self.setValue(new Date());" width="300px"/>

      Current Result

      (depending on the JDK version outputs may vary due to differenct CLDR versions)

      JDK 11 result (2021-10-14):

      Expected Result

      medium: "14 de out de 2021"
      long: "14 de outubro de 2021"

      Debug Information

      the correct date formats are provided by the server :
      medium: "d 'de' MMM 'de' y"
      long: "d 'de' MMMM 'de' y"

      notice the single quotes around the word 'de'

      When formatting the date zk.fmt.DateFormat ignores the single quotes and treats the character 'd' and 'e' as date pattern tokens (d = day of month / e = unknown resulting in a '1' https://github.com/zkoss/zk/blob/v9.6.0.1/zul/src/archive/web/js/zul/db/datefmt.js#L567-L571) hence composes the formatted date incorrectly.

      Also updating the date via calendar or typing a valid date doesn't update the component (assuming the parser also fails to treat quoted characters accordingly - https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html)

      Workaround

      avoid quoted characters in date formats

            jumperchen jumperchen
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: