• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java 8 java time package: converting Duration to miliseconds

 
Greenhorn
Posts: 6
1
  • 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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic