Java OffsetTime class

Description

Java OffsetTime class

import java.time.OffsetTime;
import java.time.ZoneOffset;

public class Main {
  public static void main(String[] args) {
    // Get the current offset time
    OffsetTime ot1 = OffsetTime.now();
    System.out.println("Current offset time: " + ot1);

    // Create a zone offset +05:30
    ZoneOffset offset = ZoneOffset.ofHoursMinutes(5, 30);

    // Create an offset time
    OffsetTime ot2 = OffsetTime.of(16, 40, 28, 0, offset);
    System.out.println("An offset time: " + ot2);


  }//from w ww  . j  a  va2s  . c  o  m
}



PreviousNext

Related