LocalDate ld = LocalDate.now();
In java, the current Date can be accessed using the method now of the LocalDate object.
The example first creates a localDate object calling the now method of the LocaleDate object. That date is converted to a String using the format method and the ISO_DATE formatter that is part of the DateTimeFormatter Object. The String is then written in the output.
import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class CurrentDateTest { public static void main(String[] argv) { LocalDate ld = LocalDate.now(); System.out.println("Date in ISO format: " + ld.format(DateTimeFormatter.ISO_DATE)); } }
Date in ISO format: 2018-08-13