Reputation: 3497
Does OffsetDateTime
isAfter
and isBefore
method handle timezones when doing comparison?
So if one OffsetDateTime
is in PST and the other one is UTC, will it automatically do the timezone conversion and compare correctly?
Upvotes: 3
Views: 6028
Reputation: 5225
This is straightforward to test!
public class Scratch {
public static void main(String... args) throws Exception {
final OffsetDateTime odtMinusSeven = OffsetDateTime.of(2016, 01, 01, 8, 30, 0, 0, ZoneOffset.ofHours(-7));
final OffsetDateTime odtMinusSix = OffsetDateTime.of(2016, 01, 01, 8, 30, 0, 0, ZoneOffset.ofHours(-6));
System.out.println(odtMinusSeven.isAfter(odtMinusSix));
// true
}
}
Upvotes: 10