Advertisement
Guest User

DateParsing

a guest
Feb 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. String format = "dd-MM-yyyy";
  2. DateTimeFormatter formatterInput = DateTimeFormatter.ofPattern(format);
  3. String dateInput = scanner.nextLine();
  4. LocalDate date = LocalDate.parse(dateInput, formatterInput);
  5.  
  6. DateTimeFormatter formatterOutput = DateTimeFormatter.ofPattern("dd/MM/yyyy");
  7.  
  8. System.out.print("The date you entered is " + formatterOuput.format(date));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement