Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@apache.org Received: (qmail 77328 invoked from network); 8 Jan 2003 06:37:15 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 8 Jan 2003 06:37:15 -0000 Received: (qmail 28797 invoked by uid 97); 8 Jan 2003 06:38:01 -0000 Delivered-To: qmlist-jakarta-archive-struts-user@jakarta.apache.org Received: (qmail 28725 invoked by uid 97); 8 Jan 2003 06:38:00 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 28661 invoked by uid 98); 8 Jan 2003 06:38:00 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: Tue, 7 Jan 2003 22:36:27 -0800 (PST) From: "Craig R. McClanahan" To: Struts Users Mailing List Subject: Re: BeanUtil and Date conversion In-Reply-To: Message-ID: <20030107223320.U363-100000@icarus.apache.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Tue, 7 Jan 2003, Dan Tran wrote: > Date: Tue, 7 Jan 2003 22:27:34 -0800 > From: Dan Tran > Reply-To: Struts Users Mailing List > To: Struts Users Mailing List > Subject: BeanUtil and Date conversion > > Hi I am able to write a DateConverter using Converter interface to > convert a specific date pattern String to Date object. This way I can > use BeanUtils.copyProperties to transparently convert a date string in > my action form to my bean. > > How do I write the converter to translate a Date object to String using > the same pattern (ie from bean to form)??? > A short term strategy that might work is to create a custom Converter for java.lang.String that recognizes if the input object is a Date or not. You can base your code on the existing class (org.apache.commons.beanutils.converters.StringConverter) and add an instanceof check. Longer term, the Converter interface probably needs to have explicit methods for converting Object->String and String->Object. > Advice is greatly appreciated. > > Happy coding > > -D > > > Craig -- To unsubscribe, e-mail: For additional commands, e-mail: