/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.time.* ;
import java.time.format.* ;
import java.time.temporal.* ;
import java.time.chrono.* ;
import java.time.zone.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
System.
out.
println( "Java vendor and version:" ) ; System.
out.
println( " " + System.
getProperty("java.vendor") ) ;
// ---------- current moment ------------------
//ZoneOffset offset = ZoneId.of( "Africa/Casablanca" ).getRules().getOffset( Instant.now() ) ;
Instant instant = Instant.now() ;
ZoneId z = ZoneId.of( "Africa/Casablanca" ) ;
ZoneRules rules = z.getRules() ;
ZoneOffset offset = rules.getOffset( instant ) ;
boolean isDst = rules.isDaylightSavings( instant ) ;
System.
out.
println( "offset.toString(): " + offset
) ; System.
out.
println( "isDst: " + isDst
) ;
// ---------- specific date ------------------
LocalDate localDate = LocalDate.parse( "2019-05-20" ) ;
ZonedDateTime zdt = localDate.atStartOfDay( z ) ;
System.
out.
println( "zdt.toString(): " + zdt
) ; "offset: " + rules.getOffset( zdt.toInstant() ) +
" | is in DST: " + rules.isDaylightSavings( zdt.toInstant() )
);
}
}