TimeUnit values() method in Java with Examples
The values() method of TimeUnit Class returns an array containing the constants of this enum type, in the order they are declared. In short, this method is used to get the Enum Constants of TimeUnit Class.
Syntax:
public static TimeUnit[] values()
Return Value: This method returns an array containing the constants of this enum type, in the order they are declared
Below program illustrate the TimeUnit values() method:
// Java program to demonstrate // values() method of TimeUnit Class import java.util.concurrent.*; class GFG { public static void main(String args[]) { System.out.println("The Enum constants " + "of TimeUnit Class " + "using TimeUnit.values() " + "are:"); // Get the array of Enum constants // using TimeUnit.values // and Iterate over them for (TimeUnit constants : TimeUnit.values()) { System.out.println(constants); } } } |
chevron_right
filter_none
Output:
The Enum constants of TimeUnit Class using TimeUnit.values() are: NANOSECONDS MICROSECONDS MILLISECONDS SECONDS MINUTES HOURS DAYS
Recommended Posts:
- TimeUnit toSeconds() method in Java with Examples
- TimeUnit convert() method in Java with Examples
- TimeUnit toHours() method in Java with Examples
- TimeUnit toNanos() method in Java with Examples
- TimeUnit toMicros() method in Java with Examples
- TimeUnit valueOf() method in Java with Examples
- TimeUnit sleep() method in Java with Examples
- TimeUnit toMillis() method in Java with Examples
- TimeUnit toDays() method in Java with Examples
- TimeUnit toMinutes() method in Java with Examples
- Provider values() method in Java with Examples
- AbstractMap values() Method in Java with Examples
- SortedMap values() method in Java with Examples
- DayOfWeek values() method in Java with Examples
- ConcurrentHashMap values() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


