TimeUnit Enum in Java

In this post, we’ll see java.util.concurrent.TimeUnit that helps organize and use time representations that may be maintained separately across various contexts with examples. We’ll also see how to use TimeUnit sleep() method in Thread context.


TimeUnit represents time duration at a given unit of granularity and provides utility methods to convert across units, and to perform timing and delay operations in these units.

The unit of time in TimeUnit can be one of:


  • DAYS : Time unit representing twenty four hours
  • HOURS : Time unit representing sixty minutes
  • MICROSECONDS : Time unit representing one thousandth of a millisecond
  • MILLISECONDS : Time unit representing one thousandth of a second
  • MINUTES : Time unit representing sixty second
  • NANOSECONDS : Time unit representing one thousandth of a microsecond
  • SECONDS : Time unit representing one second

Click here to read more

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s