Program
import java.time.LocalDate; public class DateWithoutTime { public static void main(String[] args) { LocalDate l_date = LocalDate.now(); System.out.println("Current date without time: " + l_date); } }
Output
Current date without time: 2021-04-11
Description
public static LocalDate now()
Obtains the current date from the system clock in the default time-zone.
This will query the system clock in the default time-zone to obtain the current date.
Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
Returns:
the current date using the system clock and default time-zone, not null