Advertisement
Guest User

Untitled

a guest
Jun 10th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package p01_Intro_To_Java_Lab;
  2.  
  3. import java.text.ParseException;
  4. import java.time.LocalDate;
  5. import java.time.format.DateTimeFormatter;
  6. import java.util.Scanner;
  7.  
  8. public class test2 {
  9.     public static void main(String[] args) throws ParseException {
  10.         Scanner scanner = new Scanner(System.in);
  11.  
  12.         Scanner dayScanner = new Scanner(scanner.next());
  13.  
  14.         dayScanner.useDelimiter("-");
  15.  
  16.         int x1 = dayScanner.nextInt();
  17.         int x2 = dayScanner.nextInt();
  18.         int x3 = dayScanner.nextInt();
  19.  
  20.         LocalDate a = LocalDate.of(x3, x2, x1);
  21.         LocalDate b = a.plusYears(18);
  22.  
  23.         DateTimeFormatter formatters = DateTimeFormatter.ofPattern("dd-MM-yyyy");
  24.         String finalDate = b.format(formatters);
  25.  
  26.         System.out.println(finalDate);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement