No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Display error for some dates with the MM/YYYY format

    Am using
    Browser : Chrome Ver 88.0.4324.150 (Build ufficiale) (a 64 bit)
    Smart client: version for customer 10.0, for test i have used 10.0 and 12.1

    The problem is simple, I set as date format MM/YYYY by modifying dateItem.js like this:
    {name:"directInputDate", title:"Direct Input Date", type:"date", useTextField:true, wrapTitle:false,
    change:"dateLabel.setContents(value)", dateFormatter: "MM/YYYY"}

    If you set a date greater than or equal to January 4, 2021 or less than or equal to December 31, 2020, the displayed date is correct.
    If I try a date from January 1st to January 3rd 2021 the displayed date is: 01/2020.

    I haven't tried all the dates, so I don't know of any other use cases.

    Thanks in advance for any feedback.

    Hi Enri_000,

    please see the docs for dateFormatter. Type is DateDisplayFormat, so it should be one of the strings there.

    Best regards


      Hi Blama
      Thank you for your answer.
      But I think it is necessary to clarify the problem.
      If I put a date between 1 and 3 January 2021, the displayed date is 01/2020.
      The year is wrong.
      For the other dates I tried everything is correct.


        The problem is likely just the casing of YYYY - use yyyy instead, and that should address your problem. See the doc for the "format" attribute, and FormatString, for details.
        Last edited by Isomorphic; 12 Feb 2021, 08:12.


          Hi Isomorphic,

          I can see the OP's problem in Chromium and how your suggestion from #4 solves it. But IMHO this is not in accordance with the docs, as the value should be type:DateDisplayFormat according to the docs. Also this would not work in SmartGWT's FormItem.setDateFormatter(DateDisplayFormat ddf).

          Best regards


            Yes, for clarity, the dateFormatter property takes just the string listed under DateDisplayFormat and it's the "format" property that takes format strings similar to Java's SimpleDateFormat.

            However, as an undocumented behavior (don't rely on it) we made it so that if you confuse the two properties, applying a format string to dateFormatter also works. Doesn't apply to SGWT, where the enum makes this impossible.


              Hi Isomorphic,

              OK, thanks.

              Best regards


                Hi Blama and Isomorphic .
                Thanks for your help.

                The format "yyyy" works.