TimeUnit.values() has the following syntax.
public static TimeUnit [] values()
In the following code shows how to use TimeUnit.values() method.
import java.util.concurrent.TimeUnit; //from ww w .j av a 2 s .c o m public class Main { public static void main(String[] args)throws Exception { TimeUnit[] timeUnits = TimeUnit.values(); for(TimeUnit unit:timeUnits){ System.out.println(unit); } } }
The code above generates the following result.