Code example for SimpleDateFormat

Methods: setLenient

0
{ 
  private SimpleDateFormat dateFormat;
 
  public SQLTimeValueConverter() 
  { 
    dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);
    dateFormat.setLenient(false);
  } 
 
  public String toAttributeValue(final Object o) throws BeanException
  { 
    if (o == null)
    { 
      throw new NullPointerException();
    } 
    if (o instanceof Time == false)
    { 
      throw new BeanException("Failed to convert object of type " + o.getClass() + ": Not a SQL-Time.");
    } 
    final DateFormat format = (DateFormat) dateFormat.clone();