I try to create a timer in java and show it on JFrame but when I comper my timer to my phone timer the timer in my phone is faster then my why?
I set the deley to 10 to every hundred of second in my timer.
This is the code only for the timer:
import javax.swing.Timer;
int min = 0, sec = 0, hundredSec = 0;
timer = new Timer(10, new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
hundredSec++;
if(hundredSec >= 99)
{
sec++;
hundredSec = 0;
}
if(sec >= 59)
{
min++;
sec = 0;
}
timerL.setText(String.format("%02d:%02d:%02d", min, sec, millisec));
}
});
Sorry for bad english.
Thanks in advance for answer.
actionPerformedmethod compute the difference between the current time and the start time and update the text from that.