Adding/Subtracting 5 seconds from Java Date - Showing deprected warning

后端 未结 8 845
旧巷少年郎
旧巷少年郎 2021-01-23 01:43

I want to add 5 seconds to current time

    Date date = new Date();

    date.setSeconds(date.getSeconds()+ 5);
    System.out.println(\"old Value is: \"+date);         


        
相关标签:
8条回答
  • 2021-01-23 02:29

    you can use date.setTime(date.getTime() + 5000)

    0 讨论(0)
  • 2021-01-23 02:32

    showing deprecated warning that means there is some better way available in java to do so.

    0 讨论(0)
提交回复
热议问题