Working with Dates
Easily handle date operations, including retrieving the current date and formatting it, using Java's java.time classes.
Easily handle date operations, including retrieving the current date and formatting it, using Java's java.time classes.
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class DateExample {
public static void main(String[] args) {
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
String formattedDate = currentDate.format(formatter);
System.out.println("Current date: " + formattedDate);
}
}