/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.time.*;
import java.time.temporal.ChronoUnit;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Instant start = OffsetDateTime.of( 2020 , 1 , 23 , 15 , 30 , 0 , 0 , ZoneOffset.UTC ).toInstant();
Instant stop = OffsetDateTime.of( 2020 , 1 , 23 , 15 , 30 , 0 , 0 , ZoneOffset.UTC ).plusWeeks( 7 ).toInstant();
ZoneId z = ZoneId.of( "America/Montreal" );
ZonedDateTime startZdt = start.atZone( z );
ZonedDateTime stopZdt = stop.atZone( z );
long weeksCount = ChronoUnit.WEEKS.between( startZdt , stopZdt );
System.
out.
println( "start.toString() = " + start
); System.
out.
println( "stop.toString() = " + stop
); System.
out.
println( "startZdt.toString() = " + startZdt
); System.
out.
println( "stopZdt.toString() = " + stopZdt
); System.
out.
println( "weeksCount: " + weeksCount
);
ChronoUnit
.WEEKS
.between(
java.
util.
Date.
from( start
).
toInstant().
atZone( ZoneId.
of( "Asia/Tokyo" ) ) ,
java.
util.
Date.
from( stop
).
toInstant().
atZone( ZoneId.
of( "Asia/Tokyo" ) ) )
);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgppbXBvcnQgamF2YS50aW1lLio7CmltcG9ydCBqYXZhLnRpbWUudGVtcG9yYWwuQ2hyb25vVW5pdDsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgogICAgICAgIEluc3RhbnQgc3RhcnQgPSBPZmZzZXREYXRlVGltZS5vZiggMjAyMCAsIDEgLCAyMyAsIDE1ICwgMzAgLCAwICwgMCAsIFpvbmVPZmZzZXQuVVRDICkudG9JbnN0YW50KCk7CiAgICAgICAgSW5zdGFudCBzdG9wID0gT2Zmc2V0RGF0ZVRpbWUub2YoIDIwMjAgLCAxICwgMjMgLCAxNSAsIDMwICwgMCAsIDAgLCBab25lT2Zmc2V0LlVUQyApLnBsdXNXZWVrcyggNyApLnRvSW5zdGFudCgpOwoKICAgICAgICBab25lSWQgeiA9IFpvbmVJZC5vZiggIkFtZXJpY2EvTW9udHJlYWwiICk7CgogICAgICAgIFpvbmVkRGF0ZVRpbWUgc3RhcnRaZHQgPSBzdGFydC5hdFpvbmUoIHogKTsKICAgICAgICBab25lZERhdGVUaW1lIHN0b3BaZHQgPSBzdG9wLmF0Wm9uZSggeiApOwoKICAgICAgICBsb25nIHdlZWtzQ291bnQgPSBDaHJvbm9Vbml0LldFRUtTLmJldHdlZW4oIHN0YXJ0WmR0ICwgc3RvcFpkdCApOwoKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oICJzdGFydC50b1N0cmluZygpID0gIiArIHN0YXJ0ICk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCAic3RvcC50b1N0cmluZygpID0gIiArIHN0b3AgKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oICJzdGFydFpkdC50b1N0cmluZygpID0gIiArIHN0YXJ0WmR0ICk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCAic3RvcFpkdC50b1N0cmluZygpID0gIiArIHN0b3BaZHQgKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oICJ3ZWVrc0NvdW50OiAiICsgd2Vla3NDb3VudCApOwogICAgICAgIAogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigKICAgICAgICAJCiAgICAJICAgIENocm9ub1VuaXQKCQkgICAgLldFRUtTCgkJICAgIC5iZXR3ZWVuKAoJCSAgICAgICAgamF2YS51dGlsLkRhdGUuZnJvbSggc3RhcnQgKS50b0luc3RhbnQoKS5hdFpvbmUoIFpvbmVJZC5vZiggIkFzaWEvVG9reW8iICkgKSAsIAoJCSAgICAgICAgamF2YS51dGlsLkRhdGUuZnJvbSggc3RvcCApLnRvSW5zdGFudCgpLmF0Wm9uZSggWm9uZUlkLm9mKCAiQXNpYS9Ub2t5byIgKSApIAoJCSAgICApIAogICAgICAgIAkKICAgICAgICApOwogICAgICAgIAoJfQp9