Code example for SimpleDateFormat

Methods: setLenient, setTimeZone

0
  { 
    if (parameterFormatString != null)
    { 
      try 
      { 
        final SimpleDateFormat dateFormat = new SimpleDateFormat(parameterFormatString, locale);
        dateFormat.setTimeZone(timeZone);
        dateFormat.setLenient(false);
        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); // NON-NLS
      } 
    } 
 
    return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
  }