I have made a swing application. It uses timer FOR performing certain tasks and it uses the following code get the current second:

Now, if the current second is completely divisible by 5, then a graph is updated.ie. graph gets updated every 5th second The graph should begin at time, t = 0; So, what i have done is initialised a variable 'time' to 0. When the second got from above code is divisible by 5, then graph is updated and time is incremented by 5.
Now, the graph is updated for the whole of the 5th second. Now, the problem i face is that the variable time is getting incemented by 5 twice in the 5th second...so, i am multiple values of x-axis (which corresponds to time) as the variable 'time' represents the x-axis, and hece, a wrong result.
I want the variable time to retain the same value for the whole of 5th second and get incremented by 5 in th enext 5th second.
Any idea?
Thanks!