Code example for SimpleDateFormat

Methods: setLenient, setTimeZone

0
  { 
    if (parameterFormatString != null)
    { 
      try 
      { 
        final SimpleDateFormat dateFormat = new SimpleDateFormat(parameterFormatString, new DateFormatSymbols(locale));
        dateFormat.setTimeZone(timeZone);
        dateFormat.setLenient(true);
        return dateFormat;
      } 
      catch (Exception e)
      { 
        // boo! Not a valid pattern ... 
        // its not a show-stopper either, as the pattern is a mere hint, not a mandatory thing 
        logger.warn("Parameter format-string for date-parameter was not a valid date-format-string", e);
      } 
    } 
 
    final SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_FORMAT, new DateFormatSymbols(locale));
    dateFormat.setTimeZone(timeZone);
    dateFormat.setLenient(true);