java get current date without time

java get current date without time

To get the current date without the time in Java, you can use the LocalDate class from the java.time package. This class represents a date without a time or time zone.

Here's an example of how to use the LocalDate class to get the current date without the time:

import java.time.LocalDate;

public class Main {
  public static void main(String[] args) {
    LocalDate today = LocalDate.now();
    System.out.println(today); // prints the current date in the format "yyyy-MM-dd"
  }
}
Source‮.www:‬lautturi.com

In this example, the now() method of the LocalDate class is used to get the current date. The date is then printed to the console in the format "yyyy-MM-dd".

You can use the various methods of the LocalDate class to manipulate the date, such as plusDays() to add or subtract days, or withMonth() to set the month.

Created Time:2017-11-03 22:21:08  Author:lautturi