How do I say 5 seconds from now in Java?

后端 未结 11 1833
青春惊慌失措
青春惊慌失措 2020-12-02 15:29

I am looking at the Date documentation and trying to figure out how I can express NOW + 5 seconds. Here\'s some pseudocode:

import java.util.Date
public clas         


        
11条回答
  •  青春惊慌失措
    2020-12-02 15:40

    From the one-liner-hacky dep.:

    new Date( System.currentTimeMillis() + 5000L)

    As I understand it from your example, 'now' is really 'now', and "System.currentTimeMillis()' happens to represent that same 'now' concept :-)

    But, yup, for everything more complicated than that the Joda time API rocks.

提交回复
热议问题