Getting the system start time in Java? [duplicate]
Possible Duplicate:
time since JVM started
Is there a way to get the system start time in Java?
I am trying to make some animations using the Alpha class. Alpha is a Java3D API function that models a time-dependent function into [0,1]. An Alpha instance needs to be told how many milliseconds from the system start to wait before it begins running. It calls this its triggerTime.
I want to be able to writ开发者_如何学Pythone a line of code that starts the Alpha immediately upon execution of the line. It follows that I need to know how much time has passed since the system started. In other words, I need to set alpha.triggerTime to System.currentTimeMillis() - startTime.
So how do I find this startTime? I know that I could call System.currentTimeMillis() as the first line of my code, but this animation is happening in a thread called by a different class than the one that starts the program, and I don't want to have to pass the startTime around to all of these objects. There has to be a cleaner solution.
Thanks, Jeff
'myAlpha' will start immediately upon execution of following line assuming that 'triggerTime' is '0' (startTime + triggerTime >= currentTime) :
myAlpha.setStartTime(System.currentTimeMillis());
August, InteractiveMesh
精彩评论