Using, java.time.Instant and javax.xml.datatype.XMLGregorianCalendar, I’m trying to convert from one to the other without losing precision. Why is this test not passing and how to fix it? Answer Why is this test not passing? Your XMLGregorianCalendar has got the full precision of your Instant. It’s your…
Tag: xmlgregoriancalendar
Jackson polymorphic serialization generates an incorrect class name
When I use Jackson polymorphic serialization, it generates a JSON object with an incorrect fully qualified class name. The code below serializes an XMLGregorianCalendar. The output is: I expected the following: Why does it output java.util.GregorianCalendar? Or more importantly: How do I fix this? Code exampl…
java.util.Date to XMLGregorianCalendar
Isn’t there a convenient way of getting from a java.util.Date to a XMLGregorianCalendar? Answer I should like to take a step back and a modern look at this 10 years old question. The classes mentioned, Date and XMLGregorianCalendar, are old now. I challenge the use of them and offer alternatives. Date w…