It's possible do a timed execution in Netbeans?
I want to do a timed execution for comparison of two logics.
I开发者_运维问答s it possible in Netbeans to do this or I need do code implementation?
EDIT: I want the program execute for a certain time and after that stop/shutdown, and not measure how time was spent executing.
edit: given your edit -
EDIT: I want the program execute for a certain time and after that stop/shutdown, and not measure how time was spent executing.
Then using Java's Calendar object is exactly what you need. You can call a method from within it which returns the time in milliseconds. Just keep converting it until you have the unit of comparison you desire (minutes, hours etc).
Or, even better, you could create a minimal yet complete class which provides the functionality you need without having to hardcode the conversion values :].
I am not 100% sure what you mean by 'in Netbeans' or 'code implementation'? If you wish for a program to constantly run until a certain time and then execute a method after that time has elapsed then that would not be difficult.
Java's API has Calendar objects which can return the time:
Calendar now = Calendar.getInstance();
精彩评论