Java getting current date without creating a new Date object -
i have game loops. need check current number of milliseconds. don't want create new date object number of milliseconds has passed. there way current time without creating new date object every iteration of game loop?
example:
date d = new date(); while(true) { long currenttime = d.getcurrenttime(); }
in above code, value of currenttime variable continuously change.
rather using date, can access static method
long currenttime = system.currenttimemillis()
this returns current time of given system in milliseconds.
Comments
Post a Comment