Announcement

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

    issue with datetimeformat and setusemask(true)

    Hey,

    i just found this really cool functionality you guys have for Date/DateTimeItems, setUseMask to make it easier to enter datetime data. However, since our app is in Scandinavia, we want the format of datetime to be "YYYY-mm-dd HH:mm", which is not the way it is out of the box.

    Therefor i do it in what i think is the "common" way, i.e. make DateUtil calls (see code below) to set custom formats. This has worked fine for years, but now it breaks the mask


    Basically, since the format is one thing, but the mask apparently expects another format, it gets totally wobbled up and i cant even save the form. See attached screenshot.


    Pleasse advice if there's anything i can do to make usemask work with my custom formatters (that i must have, all our customers expect it).


    Code:
    DateUtil.setNormalDateDisplayFormatter(constants.dateFormatter);
    DateUtil.setShortDateDisplayFormatter(constants.dateFormatter);
    DateUtil.setShortDatetimeDisplayFormatter(constants.datetimeFormatter);
    
    DateUtil.setDateParser(new DateParser() {
        public Date parse(String dateString) {
            try {
                return constants.dateTimeFormat.parse(dateString);
            } catch (IllegalArgumentException e) {
                try {
                    return constants.dateFormat.parse(dateString);
                } catch (IllegalArgumentException e1) {
                }
            }
            return null;
        }
    });
    Attached Files

    #2
    Some additional info:

    Basically, the java doc for setUseMask says this:
    If useTextField is not false this property determines if an input mask should be used. The format of the mask is determined by the inputFormat or dateFormatter (in that order).

    I have tried basically every method in DateUtil.set*Format* and other set methods. Nothing works, seems to be ignored in the mask. I have also tried the DateTimeItem.setInputFormat, which also had no effect.

    Not sure how to proceed.

    SmartGWT 6.0-p20161207, any browser.

    Comment


      #3
      You probably just need to call DateUtil.setInputFormat("YMD"), as well as setting the formatters - if that doesn't work for you, let us know and we'll take a look.

      In that case, please post runnable sample code that shows the issue.
      Last edited by Isomorphic; 4 Jan 2017, 01:58.

      Comment


        #4
        It worked! thanks.

        Comment

        Working...
        X