1import java.time.*;
2import java.time.format.*;
3DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
4LocalDateTime datetime = LocalDateTime.now();
5String output = formatter.format(datetime);
1import java.time.*;
2import java.time.format.*;
3DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
4LocalDate date = LocalDate.now();
5String output = formatter.format(date);
1import java.time.*;
2import java.time.format.*;
3DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
4LocalTime time = LocalTime.now();
5String output = formatter.format(time);