import java.time.ZoneOffset;
import java.util.SimpleTimeZone;
import java.util.TimeZone;

public class Test {
  
  private static void printTimezoneIsCorrect(ZoneOffset offset) {
    System.out.println("ZoneOffset: " + offset);
    System.out.println("ZoneOffset milliseconds: " + offset.getTotalSeconds() * 1000);
    
    // this does not work if the offset goes down to seconds:
    final TimeZone tz1 = TimeZone.getTimeZone(offset);
    System.out.println("TimeZone.getTimeZone: " + tz1);
    System.out.println("TimeZone.getTimeZone milliseconds: " + tz1.getRawOffset());
    
    // this is how it should look like:
    final String tzid = (offset.getTotalSeconds() == 0) ? "UTC" : "GMT".concat(offset.getId());
    final TimeZone tz2 = new SimpleTimeZone(offset.getTotalSeconds() * 1000, tzid);
    System.out.println("Manual SimpleTimeZone: " + tz2);
    System.out.println("Manual SimpleTimeZone milliseconds: " + tz2.getRawOffset());
    System.out.println();
  }
  
  public static void main(String... args) throws Exception {
    printTimezoneIsCorrect(ZoneOffset.ofTotalSeconds(3600));
    printTimezoneIsCorrect(ZoneOffset.ofTotalSeconds(3600 + 60));
    printTimezoneIsCorrect(ZoneOffset.ofTotalSeconds(3600 + 60 + 1));
    printTimezoneIsCorrect(ZoneOffset.ofTotalSeconds(-3600));
    printTimezoneIsCorrect(ZoneOffset.ofTotalSeconds(-3600 + -60));
    printTimezoneIsCorrect(ZoneOffset.ofTotalSeconds(-3600 + -60 - 1));
  }
  
}
