set timer java code example Example 1: java timer import java.util.Timer; Example 2: java timer Timer timer = new Timer();