Java OffsetDateTime convert to LocalDate

Description

Java OffsetDateTime convert to LocalDate

import java.time.LocalDate;
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);

    // Get the local date and time from the offset date time
    LocalDate ld1 = odt1.toLocalDate();
    System.out.println("Current Local Date: " + ld1);
  }//  w  w  w.  j av  a  2s.c  om
}



PreviousNext

Related