I have an ArrayList of elements with a timestamp.
Given an element of this array, I would like to select all the elements happing a certain time before and after that given element.
The problem is that this time stamp goes to 60 000 milisec and then start again from zero.
So if I would like to get all the elements happening, say 1000 milisec before and after the element with timestamp 59 999 I don’t know how to do this.
I have been looking at the modulus operation but I don’t seem able to make it work.
Try this:
This code simply check twice – once each for roll-over and non-roll-over.
I’ve tested it and it works for “roll-under” as well – ie when the target is less than 1000 (so the range would be between 59000 + target and target)