RR> I'm posting this with a different subject line so it will hopefully
 RR> come up in the archives if someone needs to search for it.


 RR> public class DateBeanUtilsConverter implements Converter {

 RR>   private String formatPattern = null;

 RR>   public void setFormatPattern(String formatPattern) {
 RR>     this.formatPattern = formatPattern;
 RR>   }

 RR>   public Object convert(Class type, Object value) {
 RR>     Date date = null;

 RR>     if (value != null && (value instanceof String) && (type ==
 RR>         Date.class)) {
 RR>         try {

 RR>             String s = value.toString();
 RR>             SimpleDateFormat formatter =
 RR>                new SimpleDateFormat(formatPattern);

It's probably better to move SimpleDateFormatter creation to
setFormatPattern method. This would help avoid unnecessary object
creations.


 RR>             date = formatter.parse(s);

 RR>         } catch (Exception e) {
 RR>             //log error
 RR>         }
 RR>     }
 RR>     return date;
 RR>   }

 RR> }

-- 
Max Kutny

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to