Announcement

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

  • Isomorphic
    replied
    We've added a setter, NumberUtil.setDecimalSymbol(), to provide access to the global setting.  However, please read the docs for its limited purpose.  It will be in SGWT 5.0p and newer in the nightly builds stamped 2015-09-18.

    Leave a comment:


  • andyx1975
    replied
    yes I am using locale=de or locale=en... but as I said... here in europe many people are speaking english. So if you offer german and english as language... the people who do not speak are using english as language. But if you have to enter US amounts and US dates it is very confusing for the people. So they want to use the english language and enter dates like dd.MM.yyyy and entering amounts like 1.000,00 because they did it their whole life. So that's why I am trying to switch the amounts and dates from US to DE while the language remains english. You know what I mean?

    t's common in Europe, that you use english systems with european notations. So there's no way to do that?

    Leave a comment:


  • Isomorphic
    replied
    That's automatically handled when using GWT's built-in locale mechanism. In fact, US vs Euro date formatting is likewise automatically handled. Perhaps you are not using GWT's locale mechanism at all and that's the root problem here?

    Leave a comment:


  • andyx1975
    replied
    Is there also a way to set the decimal Seperator and the thousand seperator globally?

    1,000.00 to 1.000,00

    Thanks!!!

    Leave a comment:


  • Isomorphic
    replied
    You didn't call setInputFormat() - call that method passing the value DMY, if that's the order you want the date-elements to be in.

    Leave a comment:


  • andyx1975
    replied
    thanks for getting back... I followed your instructions... I used the following code... which worked fine for all dateFields. I can enter now dd.MM.yyyy and it accepts as date.

    Code:
    // Sets default Week start day and date seperator
            DateUtil.setDefaultDateSeparator( "." );
            DateUtil.setFirstDayOfWeek( 1 );
    
            final String DATE_TIME_PATTERN = "dd.MM.yyyy HH:mm";
            final String DATE_PATTERN = "dd.MM.yyyy";
    
            final DateTimeFormat dateFormat = DateTimeFormat.getFormat( DATE_PATTERN );
            final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( DATE_TIME_PATTERN );
    
            DateDisplayFormatter dateFormatter = new DateDisplayFormatter()
            {
                @Override
                public String format( Date date )
                {
                    String form = dateFormat.format( date );
                    return form;
                }
            };
            DateDisplayFormatter datetimeFormatter = new DateDisplayFormatter()
            {
                @Override
                public String format( Date date )
                {
                    String form = dateTimeFormat.format( date );
                    return form;
                }
            };
    
            // Sets the Default date Seperator System wide
            DateUtil.setDefaultDateSeparator( "." );
            DateUtil.setNormalDateDisplayFormatter( dateFormatter );
            DateUtil.setShortDateDisplayFormatter( dateFormatter );
            DateUtil.setShortDatetimeDisplayFormatter( datetimeFormatter );
            DateUtil.setDateInputFormat( DATE_PATTERN );
            DateUtil.setDateParser( new DateParser()
            {
                public Date parse( String dateString )
                {
                    final DateTimeFormat format = DateTimeFormat.getFormat( DATE_PATTERN );
                    Date date = format.parse( dateString );
                    return date;
                }
            } );

    But I can not enter DateTimes anymore (like "dd.MM.yyyy HH:mm"). If I use this... I can enter DateTimes but no dates (like "dd.MM.yyyy"):

    Code:
    final String DATE_TIME_PATTERN = "dd.MM.yyyy HH:mm";
    DateUtil.setDateInputFormat( DATE_TIME_PATTERN );
     DateUtil.setDateParser( new DateParser()
            {
                public Date parse( String dateString )
                {
                    final DateTimeFormat format = DateTimeFormat.getFormat( DATE_PATTERN_TIME );
                    Date date = format.parse( dateString );
                    return date;
                }
            } );
    So what we are missing here is DateUtil.setDateTimeInputFormat and DateUtil.setDateTimeParser.

    Like you suggested... I also removed:
    DataSourceDateField requestDateField = new DataSourceDateField( request_date, constants.requestDate() ); requestDateField.setDateFormatter( DateDisplayFormat.TOEUROPEANSHORTDATE );

    Leave a comment:


  • Isomorphic
    replied
    You've implemented a parser that will not tolerate anything but a complete, perfect input, which won't work well for actual users. As the docs for setDateParser() tell you, you probably want to call setInputFormat().

    And yes, if your use case is the common one of switching between Euro and US formats system-wide, you want to just use the system-wide settings in DateUtil, and remove any component- or DataSourceField-specific settings.

    Leave a comment:


  • andyx1975
    replied
    Sorry... forgot to mention the version... So I tried today the latest version:
    https://www.smartclient.com/builds/S...GPL/2015-09-09


    When I use DateUtil with the following code... I can not enter any date... it always says that it is not a valid date.
    Code:
     // Sets default Week start day and date seperator
            DateUtil.setDefaultDateSeparator( "." );
            DateUtil.setFirstDayOfWeek( 1 );
    
    final String DATE_TIME_PATTERN = "dd.MM.yyyy HH:mm";
            final DateTimeFormat dateFormat = DateTimeFormat.getFormat( "dd.MM.yyyy" );
            final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( DATE_TIME_PATTERN );
    
            DateDisplayFormatter dateFormatter = new DateDisplayFormatter()
            {
                @Override
                public String format( Date date )
                {
                    String form = dateFormat.format( date );
                    return form;
                }
            };
            DateDisplayFormatter datetimeFormatter = new DateDisplayFormatter()
            {
                @Override
                public String format( Date date )
                {
                    String form = dateTimeFormat.format( date );
                    return form;
                }
            };
    
            // Sets the Default date Seperator System wide
            DateUtil.setDefaultDateSeparator( "." );
            DateUtil.setNormalDateDisplayFormatter( dateFormatter );
            DateUtil.setShortDateDisplayFormatter( dateFormatter );
            DateUtil.setShortDatetimeDisplayFormatter( datetimeFormatter );
            DateUtil.setDateParser( new DateParser()
            {
                public Date parse( String dateString )
                {
                    final DateTimeFormat format = DateTimeFormat.getFormat( DATE_TIME_PATTERN );
                    Date date = format.parse( dateString );
                    return date;
                }
            } );
    But when I set in my dataSource 'DateDisplayFormat.TOEUROPEANSHORTDATE' and all dates in listGrid show up like that... I guess the filter popUp for this listGrid should also use the same DatePattern.

    The reason why I switch from US format to EURO Format is, that I need an english version, but it will be used by european people... so they do not understand the date format... when they see "MM.dd.yyyy" as date they always think this means "dd.MM.yyyy".

    Leave a comment:


  • Isomorphic
    replied
    Please let us know what version of what product you are using. If you aren't already testing with the latest patched build, please test with the latest patched build.

    Also, unless you are mixing US and European date formats in the displays for a single user (seems very unlikely), you can use DateUtil to set date formats system-wide, and then settings like you've shown are unnecessary.

    Leave a comment:


  • andyx1975
    started a topic Bug: ListGrid Filter ignores DateDisplayFormat

    Bug: ListGrid Filter ignores DateDisplayFormat

    Hello,

    i found a bug... if you set a DateDisplayFormat in your DataSource the filter of a listGrid ignores the DateDisplayFormat. Attached you will find a screenshot which displays the today date in US Format (08.Sep.2015 as 09.08.2015 instead of 08.09.2015). The European Short Date will be ignored.

    Code:
     DataSourceDateField requestDateField = new DataSourceDateField( request_date, constants.requestDate() );
            requestDateField.setDateFormatter( DateDisplayFormat.TOEUROPEANSHORTDATE );
    Thanks
    Andy


Working...
X