/* 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
{
{
// ZonedDateTime
LocalDate ld = LocalDate.of ( 2017 , Month.MARCH , 12 ) ;
LocalTime lt = LocalTime.of ( 1 , 0 ) ;
ZoneId z = ZoneId.of ( "America/New_York" ) ;
ZonedDateTime zdt = ZonedDateTime.of ( ld , lt , z ) ;
ZonedDateTime zdtOneHourLater = zdt.plusHours ( 1 ) ;
System .
out .
println ( "zdt: " + zdt
) ; System .
out .
println ( "zdtOneHourLater: " + zdtOneHourLater
) ; System .
out .
println ( "Yikes! 1 AM plus an hour is 3 AM? Yes, that is an anomaly known as Daylight Saving Time (DST)." ) ;
// Instant
Instant instant = zdt.toInstant ( ) ; // Adjust into UTC. Same moment, same point on the timeline, but viewed by a different wall-clock.
Instant instantOneHourLater = instant.plus ( 1 , ChronoUnit.HOURS ) ;
System .
out .
println ( "instant: " + instant
) ; System .
out .
println ( "instantOneHourLater: " + instantOneHourLater
) ; System .
out .
println ( "Instant is always in UTC. So no anomalies, no DST. Adding an hour to 1 AM results in 2 AM every time." ) ; }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgppbXBvcnQgamF2YS50aW1lLio7CmltcG9ydCBqYXZhLnRpbWUudGVtcG9yYWwuKjsKaW1wb3J0IGphdmEudGltZS5mb3JtYXQuKjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRoc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