Java Instant convert to LocalDate

Description

Java Instant convert to LocalDate



import java.time.Instant;
import java.time.LocalDate;

public class Main {
    public static void main(String[] args) {

        LocalDate ld = getLocalDate(Instant.now());
        System.out.println("Local Date: " + ld);
    }// w  w  w.  j  ava 2  s  .  c om
    public LocalDate getLocalDate(Instant now) {
        return now.atZone(ZoneId.systemDefault())
                  .toLocalDate();
    }    
}



PreviousNext

Related