Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.LocalDate;
- import java.time.LocalTime;
- import java.time.format.DateTimeFormatter;
- import java.time.format.FormatStyle;
- import java.util.Scanner;
- public class DateAndTime {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- LocalDate anotherSummerDay = LocalDate.of(2019, 6, 8);
- System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).format(anotherSummerDay));
- System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).format(anotherSummerDay));
- System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format(anotherSummerDay));
- System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).format(anotherSummerDay));
- String europeanDatePattern = "dd.MM.yyyy";
- DateTimeFormatter europeanDateFormatter = DateTimeFormatter.ofPattern(europeanDatePattern);
- System.out.println(europeanDateFormatter.format(LocalDate.of(2020, 4, 25)));
- String timeColonPattern = "HH:mm:ss";
- DateTimeFormatter timeColonFormatter = DateTimeFormatter.ofPattern(timeColonPattern);
- LocalTime colonTime = LocalTime.of(21, 34, 52);
- System.out.println(timeColonFormatter.format(colonTime));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement