Hi, see below ...
A Dimecres 06 Novembre 2002 11:29, Max Kutny va escriure: > 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. > Keep in mind that DateFormat (and SimpleDateFormat) is not thread safe so you have to be very careful when reusing them. > > RR> date = formatter.parse(s); > > RR> } catch (Exception e) { > RR> //log error > RR> } > RR> } > RR> return date; > RR> } > > RR> } -- To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>