code: public static Date toDate(final String dateText) throws Exception {
  
          Date date = null;
          if (dateText.length() > 0) {
              date = Z_DATETIME_FORMAT.parse(dateText.trim());
              if (!validateDate(date)) {
                  throw new IllegalArgumentException();
              }
          }
          return date;
      }
docs: Parses the provided String as a date.<p>
  
  First try to parse the String with the given time format.<p>
  
  If that fails try to parse the date with the browser settings.<p>
  
  @param dateText the string representing a date
  
  @return the date created, or null if there was a parse error
  
  @throws Exception in case the text can not be parsed to a date