/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
import java.time.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
OffsetDateTime odt = OffsetDateTime.now ( ZoneId.systemDefault ( ) ) ;
ZoneOffset zoneOffsetOfOdt = odt.getOffset ( ) ;
System .
out .
println ( "ZoneId.systemDefault().toString(): " + ZoneId.
systemDefault ( ) .
toString ( ) ) ; System .
out .
println ( "odt: " + odt
) ; System .
out .
println ( "zoneOffsetOfOdt: " + zoneOffsetOfOdt
) ; System .
out .
println ( "-------------------- " ) ;
ZoneId z = ZoneId.of ( "America/Montreal" ) ;
LocalDate ld = LocalDate.of ( 2017 , 4 , 25 ) ;
ZonedDateTime zdtXmas = ld.atStartOfDay ( z ) ;
ZoneOffset zoneOffsetXmas = zdtXmas.getOffset ( ) ;
System .
out .
println ( "zdtXmas.toString(): " + zdtXmas
) ; System .
out .
println ( "zoneOffsetXmas.toString(): " + zoneOffsetXmas
) ; System .
out .
println ( "zoneOffsetXmas.getTotalSeconds(): " + zoneOffsetXmas.
getTotalSeconds ( ) ) ; System .
out .
println ( "-------------------- " ) ;
Instant instant = zdtXmas.toInstant ( ) ;
int rawOffset
= TimeZone .
getTimeZone ( "America/Montreal" ) .
getRawOffset ( ) ; int zo = z.getRules ( ) .getOffset ( instant ) .getTotalSeconds ( ) * 1000 ;
System .
out .
println ( "For ZoneId: " + z
+ " at instant: " + instant
+ " the ZoneOffset is: " + zo
+ "rawOffset: " + rawOffset
) ;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgppbXBvcnQgamF2YS50aW1lLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzI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