What's the cleanest way to convert java.sql.Timestamp
to javax.xml.datatype.XMLGregorianCalendar
?
Given that XMLGregorianCalendar
has BigDecimal
precision for fractional seconds there's no loss of precision, however I'm not sure what time zone I should set at the XMLGregorianCalendar
object given that java.sql.Timestamp
is time-zone independent.
There is an answer on SO on how to convert java.util.Date
to XMLGregorianCalendar
so I could cast my Timestamp
to java.util.Date
but that would lead to loss of precision in the sub-millisecond range which is unnecessary as the target datatype (XMLGregorianCalendar
) can hold the nanoseconds component of the source datatype (Timestamp
).