Java API Tutorial - Java TimeUnit.valueOf(String name)








Syntax

TimeUnit.valueOf(String name) has the following syntax.

public static TimeUnit valueOf(String name)

Example

In the following code shows how to use TimeUnit.valueOf(String name) method.


import java.util.concurrent.TimeUnit;

public class Main {
  public static void main(String[] args)throws Exception {
    TimeUnit timeUnit = TimeUnit.valueOf(TimeUnit.DAYS.name());
    System.out.println(timeUnit);
  }
}

The code above generates the following result.