Java Data Type How to - Remove the time part of local time to get local date only








Question

We would like to know how to remove the time part of local time to get local date only.

Answer

/*from ww  w .  j av  a  2 s  .  c o m*/
import java.time.LocalDate;
import java.time.LocalDateTime;

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

    LocalDate d = LocalDateTime.now().toLocalDate();
    System.out.println(d);
  }
}

The code above generates the following result.