Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Java 8 java time package: converting Duration to miliseconds

Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recently I needed to write a utility based on new java time package that was introduced in java 8. IMHO this package is very well designed and implemented, flexible and robust. One of the things that I needed to get is to be able to implement some functionality for duration or interval - period of time between two instants. In particular I needed to extract a number of milliseconds from instance of Duration class. In Joda package there is an Interval class that provides such functionality (method toDurationMillis()), but class Duration does not provide such method out of the box. So I wrote one. It is not a complicated method but might save some time to other fellow programmers out there. So here is the utility class. It has another method which is a wrapper for sleep() method that "swallows" the Interrupted exception. It might be useful as well.

when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
    Bookmark Topic Watch Topic
  • New Topic