Adding Years to a random date from Date class

后端 未结 9 1639
傲寒
傲寒 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:16

    Try this....

    String s = new SimpleDateFormat("YYYY").format(new Date(random_date_in_long)); // 
    int i = Integer.parseInt(s)+n;
    

提交回复
热议问题