Announcement

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

    Upgrading to latest version of 6.0p breaks datetime formatting

    Upgrade from 6.0-p20170531 to 6.0-p20171202

    Hello,

    default formatting in our app is Swedish. Therefor, we have custom formatting of for example datetime.

    We have always realized this like this:

    Code:
    DateUtil.setShortDatetimeDisplayFormatter(DateUtil.TOJAPANSHORTDATETIME);
    DateUtil.setNormalDatetimeDisplayFormatter(DateUtil.TOJAPANSHORTDATETIME);
    DateUtil.setNormalDateDisplayFormatter(DateUtil.TOJAPANSHORTDATE);
    DateUtil.setShortDateDisplayFormatter(DateUtil.TOJAPANSHORTDATE);
    DateUtil.setDefaultDateSeparator("-");
    This has caused the date and datetimes to be formatted correctly, and also edited correctly. See attached "before" screenshot
    Click image for larger version  Name:	before.png Views:	2 Size:	3.1 KB ID:	250699


    After upgrading to the 6.0p build of 20171202, this is broken. See attached "after" screenshot.
    Click image for larger version  Name:	after.png Views:	1 Size:	2.8 KB ID:	250698

    Do you know what has hanged between these two 6.0 releases that could cause this? We only changed the jar files.

    EDIT: I have found the root cause. It is the mask.

    We call

    Code:
    dateTimeItem.setUseMask(true);
    On the formItem. This seems to have changed between these two versions.

    Is there something i can change regarding the masking to make it work again?

    Hope you can get back to me asap.
    Attached Files
    Last edited by mathias; 5 Dec 2017, 04:52. Reason: Found the root cause

    #2
    Have you loaded the Swedish locale? Either way, if you've loaded no locale or a European format one, you probably just need to call setInputFormat("YMD").

    Let us know if that doesn't work for you.

    Note that any issue in date parsing/formatting is likely to cause issues in other places, like those in your other Calendar report...

    The reason this started happening, by the way, is that a bug was fixed where the framework silently ignored custom parsers and fell back to the serializable date format, which happens to work with your formats.
    Last edited by Isomorphic; 5 Dec 2017, 05:13.

    Comment


      #3
      Hey, thanks for quick turnaround.

      I think we set locale. In gwt.xml:

      <extend-property name="locale" values="en"/>
      <extend-property name="locale" values="sv_SE"/>


      Due to various things we decided to enforce Swedish date formatting globally, as described above. Has worked fine, but it seems that with the latest build, the useMask call does not respect the formatting configured via DateUtil anymore. Do you know why this has changed?


      I don't think "YMD" will work since these are datetime items? I need the time part as well.

      Comment


        #4
        See the doc for setInputFormat() - the YMD is the order in which year month and date elements are are expected when parsing dates - you need it.

        Please see our additional comment in the previous post about what changed:

        "The reason this started happening, by the way, is that a bug was fixed where the framework silently ignored custom parsers and fell back to the serializable date format, which happens to work with your formats."

        Comment


          #5
          Right, missed the last part of your first post. So i guess i need to sort this out - we need the latest update, you fixed a lot of timeline issues we have :)

          Now, I actually already tried the "YMD" and that caused the date part of the datetime firld to display OK, but the time part disappeared.
          I then read the doc, and it says "For fields of type "date"". And the doc for DateInputFormat only mention "YMD", nothing about time formatting. That caused me to believe it was not applicable for DateTime formitems.

          Am i looking in the wrong place?

          Comment


            #6
            That doesn't really make any sense - the inputFormat is for the date-portion of all date/datetime formats, but setting it will not remove time portions from strings.

            And, in this case, if you've actually loaded the sv_SE locale (and you see framework strings, like menu-items in a ListGrid's content menu, in Swedish) then the inputFormat *and all the other details you've set up* are already present in that locale - so you shouldn't need any of the code you've shown in this thread.

            Firstly - check that you're actually using the Swedish locale, and not the "en" one - if you are, remove all your calls to set up formatters, because they should already be set to the same values by the locale.

            If that doesn't make things work again, please show the source for the item that's not working.

            Comment


              #7
              OK, here's a test case. When i run the below case with 6.0, the time portion is NOT displayed. If i comment out the "setInputFormat()", the time portion appears.

              Code:
              public void onModuleLoad() {
                  VLayout mainLayout = new VLayout();
                  mainLayout.setWidth(500);
                  mainLayout.setHeight(300);
                  mainLayout.setLayoutTopMargin(20);
                  DateUtil.setShortDatetimeDisplayFormatter(DateUtil.TOJAPANSHORTDATETIME);
                  DateUtil.setNormalDatetimeDisplayFormatter(DateUtil.TOJAPANSHORTDATETIME);
                  DateUtil.setNormalDateDisplayFormatter(DateUtil.TOJAPANSHORTDATE);
                  DateUtil.setShortDateDisplayFormatter(DateUtil.TOJAPANSHORTDATE);
                  DateUtil.setDefaultDateSeparator("-");
              
                  DynamicForm form = createForm();
                  mainLayout.addMember(form);
              
                  form.setValue("datetime", new Date());
                  mainLayout.draw();
              
              
              }
              
              
              private DynamicForm createForm(){
                  form = new DynamicForm();
                  form.setNumCols(3);
                  DateTimeItem dateTimeItem = new DateTimeItem("datetime", "datetime");
                  dateTimeItem.setRequired(true);
                  dateTimeItem.setAlign(Alignment.LEFT);
                  dateTimeItem.setTextAlign(Alignment.LEFT);
                  dateTimeItem.setUseMask(true);
              
                  dateTimeItem.setInputFormat("YMD");//CAUSES TIME PART TO DISAPPEAR!
              
                  form.setItems(dateTimeItem);
                  return form;
              }
              .gwt:
              Code:
               <?xml version="1.0" encoding="UTF-8"?> <module rename-to="test">      <inherits name='com.google.gwt.user.User'/>     <inherits name="com.smartgwt.tools.SmartGwtTools"/>     <inherits name="com.smartgwtee.SmartGwtEENoTheme"/>     <inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlue"/>       <inherits name="com.google.gwt.i18n.I18N"/>     <inherits name="com.google.gwt.maps.Maps"/>      <!-- English language, independent of country -->     <extend-property name="locale" values="en"/>     <!-- Swedish language -->     <extend-property name="locale" values="sv_SE"/>       <entry-point class='*****.Test'/>     <!-- Set to compile fewer permutations to reduce build time in development          Options are: ie6,ie8,gecko,gecko1_8,safari,opera -->     <set-property name="user.agent" value="gecko1_8, safari"/>     <!--set-property name="user.agent" value="gecko1_8, ie8, safari"/-->      <!-- Specify the paths for translatable code -->     <source path='client'/>     <source path='gwtcommons'/>      <add-linker name="xsiframe"/>     <set-configuration-property name="devModeRedirectEnabled" value="true"/>     <set-property name="compiler.useSourceMaps" value="true"/>     <collapse-all-properties/> </module>

              Comment


                #8
                You need to call DateUtil.setInputFormat(), the global setter, not the one on the item.

                However, you didn't answer whether you are actually seeing Swedish translations?

                If you're not using the Swedish locale, you'll need to call both DateUtil.setInputFormat(YMD) and also setDateParser(), if your formats are different from the en ones.

                Comment


                  #9
                  Ah, gotcha! I can confirm that it seems to work. So, in the end, the only thing i had to do was to add a row to my global formatting calls - DataUtil.setInputFormat("DMY");

                  As for locale - yes i see translations, like usual. Just FYI, our localization is a tad special.

                  We set the locale when the user log in, based on the user account language setting, via JSP:
                  Code:
                   
                   <meta content="locale=<%=locale%>" name="gwt:property"/>
                  However, regardless of locale/account settting, we always want to display date/time using the Swedish format. Hence why we always set the global formatting rules.


                  Thanks for your help!

                  Comment

                  Working...
                  X