https://kotlinlang.org logo
#getting-started
Title
# getting-started
k

Kenneth

02/10/2022, 11:21 AM
Is there an easy way to go from Instant to XMLGregorianCalendar in Kotlin?
s

Sam

02/10/2022, 11:27 AM
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

Stephan Schroeder

02/10/2022, 1:42 PM
Some bikeshedding: I'd replace the
Copy code
{
    return newXML...
}
in your solution with
Copy code
= this.newXML...
t

therealbluepandabear

02/11/2022, 5:05 AM
@Sam it's not a Java question at all?
s

Sam

02/11/2022, 8:10 AM
The classes and methods here are all Java, but Kotlin does do a lot to make it more convenient and less verbose 👍
45 Views