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

Minh Hoang TO (JIRA) jira-events at lists.jboss.org
Wed Jul 6 22:50:23 EDT 2011


     [ https://issues.jboss.org/browse/GTNPORTAL-1944?page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel\#worklog-{worklog.getId()} ]

Minh Hoang TO logged work on GTNPORTAL-1944:
--------------------------------------------

                Author: Minh Hoang TO
            Created on: 06/Jul/11 10:50 PM
            Start Date: 06/Jul/11 10:49 PM
    Worklog Time Spent: 4 hours 

Issue Time Tracking
-------------------

    Remaining Estimate: 0 minutes  (was: 4 hours)
            Time Spent: 4 hours
            Worklog Id:     (was: 12424777)


> 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
>            Assignee: Minh Hoang TO
>              Labels: portal-s56, worked
>   Original Estimate: 4 hours
>          Time Spent: 4 hours
>  Remaining Estimate: 0 minutes
>
> 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