Java OffsetDateTime convert to LocalTime

Description

Java OffsetDateTime convert to LocalTime

import java.time.LocalTime;
import java.time.OffsetDateTime;

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

    LocalTime lt1 = odt1.toLocalTime();
    System.out.println("Current Local Time: " + lt1);
  }//from  w ww  . j a  v  a 2 s .co m
}



PreviousNext

Related