/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.time.* ;
import java.time.temporal.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Instant phoneCallStartedUtc = Instant.now() ; // A moment as seen in UTC.
ZonedDateTime phoneCallStartedCasablanca = phoneCallStartedUtc.atZone( ZoneId.of( "Africa/Casablanca" ) ) ;
ZonedDateTime phoneCallStartedTokyo = phoneCallStartedUtc.atZone( ZoneId.of( "Asia/Tokyo" ) ) ;
System.
out.
println( "phoneCallStartedUtc.toString(): " + phoneCallStartedUtc
) ; System.
out.
println( "phoneCallStartedCasablanca.toString(): " + phoneCallStartedCasablanca
) ; System.
out.
println( "phoneCallStartedTokyo.toString(): " + phoneCallStartedTokyo
) ;
// Store these three values.
ZoneId zoneIdRome = ZoneId.of( "Europe/Rome" ) ;
LocalTime restaurantOpening = LocalTime.of( 9 , 30 ) ; // 09:30 AM.
LocalDate nextTuesday = LocalDate.now( zoneIdRome ).with( TemporalAdjusters.next( DayOfWeek.TUESDAY ) ) ;
// Do NOT store this next value. Use this next value only on-the-fly at runtime.
ZonedDateTime momentWhenRestaurantIsExpectedToOpenNextTuesday =
ZonedDateTime.of( nextTuesday , restaurantOpening , zoneIdRome ) ;
System.
out.
println( "restaurantOpening.toString(): " + restaurantOpening
) ; System.
out.
println( "nextTuesday.toString(): " + nextTuesday
) ; System.
out.
println( "momentWhenRestaurantIsExpectedToOpenNextTuesday.toString(): " + momentWhenRestaurantIsExpectedToOpenNextTuesday
) ;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgppbXBvcnQgamF2YS50aW1lLiogOwppbXBvcnQgamF2YS50aW1lLnRlbXBvcmFsLiogOwoKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHR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