Page 1 of 1

DateChooser validation error when french language is used

Posted: Wed Jul 31, 2013 2:32 pm
by denis
Hi all,

I have opened a issue :https://github.com/BroadleafCommerce/BroadleafCommerce/issues/204 because there is a problem when we use the french translation on GWT admin. Smartgwt datechooser is translated in french but when you select a date, the form expect a date with english format MM/DD/YYYY.

Image

I have opened several threads on smartgwt forum and stackoverflow (http://stackoverflow.com/questions/17931657/smartgwt-2-5-datasourcedatetimefield-i18n-validation-error) but i'm still unable to resolve the issue.

Is there someone that could help me?

Thanks in advance

Re: DateChooser validation error when french language is used

Posted: Sat Aug 03, 2013 4:03 am
by denis
Problem solved. You have to use the code below during application initialization (e.g EntryPoint) :

Code: Select all

private static final String DATE_FORMAT = "dd/MM/yyyy HH:mm";

public void onModuleLoad() {   
        DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter() {     
            @Override
            public String format(Date date) {
                if(date != null)
                {
                    final DateTimeFormat dateFormatter = DateTimeFormat.getFormat(DATE_FORMAT);
                    return dateFormatter.format(date);
                }
                return null;
            }
        });

        DateUtil.setDateParser(new DateParser()
          {
             public Date parse(String dateString)
             {
                 try{
                     if(dateString != null){
                         final DateTimeFormat format = DateTimeFormat.getFormat(DATE_FORMAT);
                         return format.parse(dateString);
                     }
                 }catch(Exception e){
                     e.printStackTrace();
                 }
                 return null;
             }
          });
}

Re: DateChooser validation error when french language is used

Posted: Sun Aug 04, 2013 2:53 pm
by phillipuniverse
Thanks for reporting back with the fix!