logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

RE: Digester type conversion: msg#00078

Subject: RE: Digester type conversion
Problem solved.  I used digester.addCallMethod(...);

-----Original Message-----
From: Jim Henderson [mailto:jgh@xxxxxxxxxxxx]
Sent: Monday, September 20, 2004 10:59 AM
To: xerces-j-user@xxxxxxxxxxxxxx
Subject: Digester type conversion




I am trying to process an XML document that defines a date as:

    ?<CreationDate>1999/03/23</CreationDate>?

The Java object I am trying to populate defines the attribute as:

    private Date docCreationDate = null;

    public void setDocCreationDate(String docCreationDate)
        throws SAXException
    {
        this.docCreationDate = (docCreationDate == null)
                             ? null
                             : stringToDate(docCreationDate);
    }


The digester rule I am using is:
    digester.addBeanPropertySetter("*/Document/CreationDate",
"docCreationDate");


If I change (type Date changed to String):
    "private Date docCreationDate = null;"
to:
    "private String docCreationDate = null;"
then the setter is called.


How do I force the setter to be called when the Java object docCreationDate
is defined as a Date object rather than a String?

Thanks,
Jim


<Prev in Thread] Current Thread [Next in Thread>