Win a copy of Python Continuous Integration and Delivery this week in the Python 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Calculating Process Time  RSS feed

 
Ranch Hand
Posts: 1931
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cannot figure out why I keep getting a value of 0.



Console:
DimensionSheetDataConnectorV8(1): 7703343 - 0
 
Marshal
Posts: 63409
205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check the TimeUnit documentation; if you are simply doing integer division by 10⁹, that result will be truncated to 0.
 
Sheriff
Posts: 13160
219
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are converting from nanoseconds to seconds, from a finer to a coarser granularity. The JavaDocs say this about such conversions:

Conversions from finer to coarser granularities truncate, so lose precision. For example converting 999 milliseconds to seconds results in 0.

 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!