Hi Fred,
In its current form, its not locale-sensitive on date conversion (that could
be fixed), but it served my needs for converting previously validated
strings. It also supports going the other direction, ie., converting a Date
object to a formatted String. Support for other types could be easily added
too.
private StringConverter sc = new StringConverter();
// snippet from populating my Form
this.setBirthDate(null == contact.getBirthDate()
? null : sc.formatDate(contact.getBirthDate()));
// snippet from getting my domain object from the form
contact.setBirthDate(null == getBirthDate()
? null : sc.toDate(getBirthDate()));
Hope its useful,
Levi
-----Original Message-----
From: Fred Lo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 12, 2001 5:25 AM
To: [EMAIL PROTECTED]
Subject: PropertyUtils.copyProperties
Hi all,
I just wonder if anyone have a utility class that is perform something to
PropertyUtils.copyProperties() but with type conversion?
The reason is that I am coding all my ActionForm with string (for validation
concern) but the underlying objects are in their respective type, so there
is some tedious coding that copy the properties from the form/object back
and forth.
Any help will be appreciated.
Fred
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
StringConverter.java
StringValidator.java