Java ZoneOffset class

Introduction

Java ZoneOffset class represents a fixed zone offset from UTC time zone, for example, +05:00, -06:00, etc.

import java.time.ZoneOffset;

public class Main {
  public static void main(String[] args) {
    // Create zone offset using hour, minute, and second
    ZoneOffset zos1 = ZoneOffset.ofHours(-6);
    ZoneOffset zos2 = ZoneOffset.ofHoursMinutes(5, 30);
    ZoneOffset zos3 = ZoneOffset.ofHoursMinutesSeconds(8, 30, 45);
    System.out.println(zos1);/*  ww  w.  j  a v  a2s  .  co  m*/
    System.out.println(zos2);
    System.out.println(zos3);

  }
}



PreviousNext

Related