I don't know about swing.timer, but there's always System.nanoTime().
I don't think there's any built in functions to get milliseconds or microseconds, but that's easily achieveable through the nanosecond timer (bear in mind that it isn't to be expected to be perfect down to nanoseconds; that's just its resolution).
public class Timer {
private long startTime;
public Timer() {
this.startTime = getMilliseconds();
}
public long getMilliseconds() {
return System.nanoTime() / 1000000
}
public void restartTimer() {
// Simply resets the startTime variable
startTime = getMilliseconds();
}
// Retrieves the time (in milliseconds) since the timer was started
public long getTime()
return getTime(false);
}
// Overloaded version of the above; set the flag to true to
// reset the timer directly after retrieving the current time
public long getTime(boolean flag)
long t = getMilliseconds() - startTime;
if(flag) restartTimer();
return t;
}
}