[gatein-issues] [JBoss JIRA] Updated: (GTNPORTAL-1944) DateTimeValidator has superflous code that breaks localized date timestamps

Trong Tran (JIRA) jira-events at lists.jboss.org
Tue Jul 5 00:13:23 EDT 2011


     [ https://issues.jboss.org/browse/GTNPORTAL-1944?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trong Tran updated GTNPORTAL-1944:
----------------------------------

     Original Estimate: 4 hours
    Remaining Estimate: 4 hours


> DateTimeValidator has superflous code that breaks localized date timestamps
> ---------------------------------------------------------------------------
>
>                 Key: GTNPORTAL-1944
>                 URL: https://issues.jboss.org/browse/GTNPORTAL-1944
>             Project: GateIn Portal
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: WebUI
>    Affects Versions: 3.1.0-GA
>            Reporter: Matt Davis
>              Labels: portal-s56
>   Original Estimate: 4 hours
>  Remaining Estimate: 4 hours
>
> http://anonsvn.jboss.org/repos/gatein/epp/portal/tags/EPP_5_1_0_GA/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
> has an additional check where the date input value needs to match the (not localized) DATETIME_REGEX, which is superfluous and causes localized date input to fail:
> Index: core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
> ===================================================================
> --- core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java	(revision 6667)
> +++ core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java	(working copy)
> @@ -43,17 +43,11 @@
>  
>  public class DateTimeValidator implements Validator
>  {
> -   static private final String SPLIT_REGEX = "/|\\s+|:";
> -
> -   static private final String DATETIME_REGEX =
> -      "^(\\d{1,2}\\/\\d{1,2}\\/\\d{1,4})\\s*(\\s+\\d{1,2}:\\d{1,2}:\\d{1,2})?$";
> -
>     public void validate(UIFormInput uiInput) throws Exception
>     {
>        if (uiInput.getValue() == null || ((String)uiInput.getValue()).trim().length() == 0)
>           return;
>        String s = (String)uiInput.getValue();
> -      DateFormat stFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
>        UIFormDateTimeInput uiDateInput = (UIFormDateTimeInput)uiInput;
>        SimpleDateFormat sdf = new SimpleDateFormat(uiDateInput.getDatePattern_().trim());
>  
> @@ -79,24 +73,5 @@
>        {
>           throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args, ApplicationMessage.WARNING));
>        }
> -      if (s.matches(DATETIME_REGEX) && isValidDateTime(s))
> -         return;
> -
> -      throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args, ApplicationMessage.WARNING));
>     }
> -
> -   private boolean isValidDateTime(String dateTime)
> -   {
> -      String[] arr = dateTime.split(SPLIT_REGEX, 7);
> -      int valid = Integer.parseInt(arr[0]);
> -      if (valid < 1 || valid > 12)
> -         return false;
> -      Calendar date = new GregorianCalendar(Integer.parseInt(arr[2]), valid - 1, 1);
> -      if (Integer.parseInt(arr[1]) > date.getActualMaximum(Calendar.DAY_OF_MONTH))
> -         return false;
> -      if (arr.length > 3
> -         && (Integer.parseInt(arr[3]) > 23 || Integer.parseInt(arr[4]) > 59 || Integer.parseInt(arr[5]) > 59))
> -         return false;
> -      return true;
> -   }
>  }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the gatein-issues mailing list