Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Hands On Software Engineering with Python this week in the Jython/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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Calculating Process Time  RSS feed

 
Ranch Hand
Posts: 1912
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: 62172
193
  • 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: 12814
211
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.

 
That's a very big dog. I think I want to go home now and hug this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!