From d728e81d6921565e04ce4b3c19846f5ce38b7f4d Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Sat, 16 Oct 2004 18:20:46 +0000 Subject: [PATCH] Document how to format a date from bug 21663 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137987 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/lang/builder/ToStringStyle.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/commons/lang/builder/ToStringStyle.java b/src/java/org/apache/commons/lang/builder/ToStringStyle.java index 03a4f9831..266e77821 100644 --- a/src/java/org/apache/commons/lang/builder/ToStringStyle.java +++ b/src/java/org/apache/commons/lang/builder/ToStringStyle.java @@ -43,12 +43,26 @@ import org.apache.commons.lang.SystemUtils; *

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.

+ * + *

If you want to format the output of certain objects, such as dates, you + * must create a subclass and override a method. + *

+ * 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);
+ *   }
+ * }
+ * 
+ *

* * @author Stephen Colebourne * @author Gary Gregory * @author Pete Gieser * @since 1.0 - * @version $Id: ToStringStyle.java,v 1.34 2004/10/16 18:13:34 scolebourne Exp $ + * @version $Id: ToStringStyle.java,v 1.35 2004/10/16 18:20:46 scolebourne Exp $ */ public abstract class ToStringStyle implements Serializable {