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 HH:mm:ss");
4String input = "2021-02-05 13:07:35";
5LocalDateTime datetime = LocalDateTime.parse(input, formatter);
1import java.time.*;
2import java.time.format.*;
3DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
4String input = "13:07:35";
5LocalTime time = LocalTime.parse(input, formatter);
1import java.time.*;
2import java.time.format.*;
3DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
4String input = "2021-02-05";
5LocalDate date = LocalDate.parse(input, formatter);
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);