• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hundredth of a second, how to format?  RSS feed

 
Sujatha Kalluri
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I find the hudredth of a second, Timestamp is giving nano second and the SimpleDateFormat can format date to seconds or milliseconds, but I didn't find hundred of a second, I need to format date as hh:mm:ss:HH(HH is defined as hundredth of second in my requirements). I have less time for it thus posted online for any hints.

thanks,
Sujatha.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could use math:

or

Or you could take the String for milliseconds and omit the last character:

There's a very minor problem, possibly, that these methods all truncate rather than round. If you want proper rounding, you can modify the first two methods, e.g.
 
Sujatha Kalluri
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks jim
seems to be working, and I guess it is the best way to get hundredth of second accurately.
Just a correction in your code of SimpleDateFormat("mmm") I think you wanted to mention it as SimpleDateFormat("SS"); as SS(uppercase) is defined for millisecond.

thanks once again.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!