Is it possible to freeze System.currentTimeMillis() for testing

前端 未结 6 2551
孤街浪徒
孤街浪徒 2021-02-20 02:24

For some testing purposes I would like to predict exactly what System.currentTimeMillis() will return. Is there any way in which I can freeze or manually set what w

6条回答
  •  耶瑟儿~
    2021-02-20 02:56

    No, You cann't set or freeze System.currentTimeMills(). But if your requirement is something like that so in that case you can set time in variable and used when ever you want.but System.currentTimeMills() will always returns you the current time value in milliseconds.

提交回复
热议问题