It is easier to track act cycles instead of time itself. Just add an instance int field to the class of the pacman and have it increment in the act method, checking for a specific number of cycles to have passed; when, you would reset the field back to zero and change the image to that which it is currently not.
If you do want exact time (by milliseconds), there is a Date class that you can import. There is a method where it gives the milliseconds after 1-1-1970 00:00:00 GMT (in a long). The long will never reset, unlike the other methods in the class.