Adding Years to a random date from Date class

后端 未结 9 1641
傲寒
傲寒 2020-12-06 10:19

Let\'s say I have this:

 PrintStream out = System.out;
 Scanner in = new Scanner(System.in);
 out.print(\"Enter a number ... \");
 int n = in.nextInt();
         


        
9条回答
  •  一生所求
    2020-12-06 11:09

    This will add 3 years to the current date and print the year.

     System.out.println(LocalDate.now().plusYears(3).getYear());
    

提交回复
热议问题