private static int msFromTime(double time){ double result = time % msPerSecond; if (result < 0) result += msPerSecond; return (int)result; }