A question, good sirs.
I have this project that I am developing and I am stuck on one thing. I am making a computer terminal timer program that will log-in a user and then from the moment he starts using the computer terminal, a timer will start and end when he desires to end his usage of the said terminal. Also, the time that he has used will be stored in a database and will be added to previous (if there are) data of his usage.
May I ask how can a timer be implemented? I will be using Netbeans with JavaSE. Thanks in advance. :)
Hi Tralalah and welcome to the forum :)
Easiest way to measure execution of your terminal work is simply this :
That will be time in milliseconds.
long startTime = System.currentTimeMillis ();
long endTime = System.currentTimeMillis ();
System.out.println ("Terminal worked for: " + (endTime - startTime));
You can easily convert it to some Date/Time format you need in app logic or proper DB column type (look for java.util.Date and java.text.SimpleDateFormat, java.sql.Date and similar classes)
Is this good enough?
FON, thanks so much. I'll try it later. :)
You are very welcome and @Aseem grats on becoming "senior member".
Now you are on holy mission of helping Java developers worldwide,
and there's no going back :D