/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.time.*;
import java.time.temporal.*;
import java.time.format.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
java.
util.
Date myJavaUtilDate1
= java.
util.
Date.
from ( Instant.
now ( ) ); java.
util.
Date myJavaUtilDate2
= java.
util.
Date.
from ( Instant.
now ( ).
minus ( 6, ChronoUnit.
HOURS ) );
Instant instant1 = myJavaUtilDate1.toInstant ( );
Instant instant2 = myJavaUtilDate2.toInstant ( );
ZoneId z = ZoneId.of ( "America/Montreal" );
ZonedDateTime zdt1 = instant1.atZone ( z );
ZonedDateTime zdt2 = instant2.atZone ( z );
LocalDate localDate1 = zdt1.toLocalDate ( );
LocalDate localDate2 = zdt2.toLocalDate ( );
Boolean sameDate
= localDate1.
isEqual ( localDate2
);
System.
out.
println ( "instant1: " + instant1
+ " | instant2: " + instant2
); System.
out.
println ( "zdt1: " + zdt1
+ " | zdt2: " + zdt2
); System.
out.
println ( "localDate1: " + localDate1
+ " | localDate2: " + localDate2
); System.
out.
println ( "sameDate: " + sameDate
);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgppbXBvcnQgamF2YS50aW1lLio7CmltcG9ydCBqYXZhLnRpbWUudGVtcG9yYWwuKjsKaW1wb3J0IGphdmEudGltZS5mb3JtYXQuKjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgogICAgICAgIGphdmEudXRpbC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