scolebourne 2004/10/16 11:20:46 Modified: lang/src/java/org/apache/commons/lang/builder ToStringStyle.java Log: Document how to format a date
from bug 21663 Revision Changes Path 1.35 +15 -1 jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToStringStyle.java Index: ToStringStyle.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToStringStyle.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- ToStringStyle.java 16 Oct 2004 18:13:34 -0000 1.34 +++ ToStringStyle.java 16 Oct 2004 18:20:46 -0000 1.35 @@ -43,6 +43,20 @@ * <p>For example, the detail version of the array based methods will * output the whole array, whereas the summary method will just output * the array length.</p> + * + * <p>If you want to format the output of certain objects, such as dates, you + * must create a subclass and override a method. + * <pre> + * public class MyStyle extends ToStringStyle { + * protected void appendDetail(StringBuffer buffer, String fieldName, Object value) { + * if (value instanceof Date) { + * value = new SimpleDateFormat("yyyy-MM-dd").format(value); + * } + * buffer.append(value); + * } + * } + * </pre> + * </p> * * @author Stephen Colebourne * @author Gary Gregory --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]