[Opensource] SimpleDateFormat
Ben Switzer
ben at site85.com
Tue Mar 11 11:37:46 PST 2003
Good day all.
I've been contemplating how best to format dates on an application wide
basis. What I've done is as follows:
in DBObject.java added method:
public String getFieldDateFormatted(String fieldName, String
pattern)
throws DBException {
return jdbcUtil.getDateFieldFormatted(this, fieldName,
pattern);
}
in JDBCUtil.java added method:
public String getDateFieldFormatted(DataObject theObject, String
fieldName, String pattern)
throws DataException {
String formattedString;
synchronized(dateConvertFormatMap) {
SimpleDateFormat formatter =
getSimpleDateFormat(pattern);
formattedString =
formatter.format(this.getDateField(theObject, fieldName));
}
return formattedString;
}
I then use getFieldDateFormatted as I would gateFieldDate in my
controller, except I supply a SimpleDateFormat pattern to get a nicely
formatted String back. I'm not one modify the expresso objects in my
apps directly, but I wasn't sure how else to achieve this quickly and
universally through my app. Any suggestions or comments?
Best,
Ben Switzer [ben at site85.com]
site85.developer.*;
phone.416.466.4509;
More information about the Opensource
mailing list