You can get the current date using LocalDate in Java by using the static now() method of the LocalDate class.
Let's see a few examples:
import java.time.LocalDate;
public class DateExample {
public static void main(String... args) {
LocalDate currentDate = LocalDate.now();
System.out.println("The Current Date Is: " + currentDate);
}
}
We have made use of the LocalDate class from the java.time package, which was introduced in Java 8 as a part of the new Date Time API.
If you want to know the date of a specific city, you will need to make use of the ZoneId class.
Example:
import java.time.LocalDate;
import java.time.ZoneId;
LocalDate currentDateInNewYork = LocalDate.now(ZoneId.of("America/New_York"));
LocalDate currentDateInLondon = LocalDate.now(ZoneId.of("Europe/London"));
System.out.println("Current Date in New York: " + currentDateInNewYork);
System.out.println("Current Date in London: " + currentDateInNewYork);

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!