users@jaxb.java.net

xsd:date with finer resolution

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Sun, 28 Jun 2009 00:48:39 -0400

Hi,

I want to map xsd:date to a java.util.Date but I want to do it with
millisecond resolution. What are my best options for doing this?
This is for a jersey application so having my own custom parse/print
class isn't a great option. My first attempt was this:

            <xsd:element name="timestamp" type="xsd:date">
                <xsd:annotation>
                    <xsd:appinfo>
                        <jaxb:javaType
                            name="java.util.Date"
                            xmlType="xsd:date"

printMethod="javax.xml.bind.DatatypeConverter.printDate"

parseMethod="javax.xml.bind.DatatypeConverter.parseDate"/>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>

It didn't work out so well. I suppose I could just use a long, but I
was hoping to have a little bit stronger typing than that. Basically,
all I need is a date/time but with msec resolution.

--Chris