Groovy web console

subscribe to the feed Subscribe
to this
site

ZonedDateTime comparison

Published 2 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
    import java.time.ZonedDateTime
    
    ZonedDateTime t1 = ZonedDateTime.parse("2018-04-06T16:01:00.000+03:00")
    ZonedDateTime t2 = ZonedDateTime.parse("2018-04-06T10:01:00.000-03:00")
    
    println t1.equals(t2)
    
    println t1.toInstant().compareTo(t2.toInstant())