Is there an easy way to go from Instant to XMLGreg...
# getting-started
k
Is there an easy way to go from Instant to XMLGregorianCalendar in Kotlin?
s
Something like this:
Copy code
fun DatatypeFactory.newXMLGregorianCalendar(
    instant: Instant,
    zoneId: ZoneId = ZoneId.systemDefault()
): XMLGregorianCalendar {
    return newXMLGregorianCalendar(GregorianCalendar.from(instant.atZone(zoneId)))
}
In a lot of ways this is really a Java question
👎 1
s
Some bikeshedding: I'd replace the
Copy code
{
    return newXML...
}
in your solution with
Copy code
= this.newXML...
t
@Sam it's not a Java question at all?
s
The classes and methods here are all Java, but Kotlin does do a lot to make it more convenient and less verbose 👍