Java Date Time Java Java API
java.time.OffsetTime
public boolean isBefore(OffsetTime other)
Checks if this OffSetTime is after the provided one. It compares the two dates after converting them to epoch nanos:
public boolean isBefore(OffsetTime other) { return toEpochNano() < other.toEpochNano();}
package com.logicbig.example.offsettime;import java.time.OffsetTime;import java.time.ZoneOffset;public class IsBeforeExample { public static void main(String... args) { OffsetTime d1 = OffsetTime.of(17, 40, 33, 20000, ZoneOffset.ofHours(-6)); System.out.println(d1); OffsetTime d2 = OffsetTime.of(10, 20, 15, 100, ZoneOffset.ofHours(-6)); System.out.println(d2); boolean b = d1.isBefore(d2); System.out.println(b); }}
17:40:33.000020-06:0010:20:15.000000100-06:00false
package com.logicbig.example.offsettime;import java.time.OffsetTime;import java.time.ZoneOffset;public class IsBeforeExample2 { public static void main(String... args) { OffsetTime d1 = OffsetTime.of(17, 40, 33, 20000, ZoneOffset.ofHours(-6)); System.out.println(d1); OffsetTime d2 = OffsetTime.of(10, 20, 15, 100, ZoneOffset.ofHours(-14)); System.out.println(d2); boolean b = d1.isBefore(d2); System.out.println(b); }}
17:40:33.000020-06:0010:20:15.000000100-14:00true