Java Date Time Java Java API
Class:
java.time.OffsetDateTime
Method:
public boolean isEqual(OffsetDateTime other)
Checks if the instant of this OffsetDateTime is equal to that of the specified one.
This is equivalent to using dateTime1.toInstant().equals(dateTime2.toInstant()) .
Examples
package com.logicbig.example.offsetdatetime;
import java.time.*;
public class IsEqualExample {
public static void main (String... args) { OffsetDateTime d = OffsetDateTime.of(LocalDateTime.of(2010, 10, 3, 12, 0), ZoneOffset.ofHours(-6));
OffsetDateTime d2 = OffsetDateTime.of(LocalDate.of(2010, 10, 3), LocalTime.NOON, ZoneOffset.ofHours(-5)); boolean b = d.isEqual(d2); System.out.println(b); } }
Outputfalse
package com.logicbig.example.offsetdatetime;
import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneOffset;
public class IsEqualExample2 {
public static void main (String... args) { OffsetDateTime d = OffsetDateTime.of(LocalDateTime.of(2010, 10, 3, 11, 0), ZoneOffset.ofHours(-6));
OffsetDateTime d2 = OffsetDateTime.of(LocalDate.of(2010, 10, 3), LocalTime.NOON, ZoneOffset.ofHours(-5)); boolean b = d.isEqual(d2); System.out.println(b); } }
Outputtrue
|
|