• 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

subtract/add date

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just want to measure the time taken for the completion of process to the finest millisecond possible.
Say,
Start time,
End time.
Time difference..
If it is run as a batch process, then the time difference will be accumulated and be printed at the end.
Which is the best method to implement this?
Please reply ASAP
Thanks & Regards,
Nijeesh.
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this is what you are asking:
1. Get start time
2. Start process
3. End process
4. Get end time
5. Calculate time between start & end
6. Repeat
7. Print out time difference when done


Is this what you were asking?
[ November 26, 2002: Message edited by: David Duran ]
 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
This is what I was looking for except for the fact the difference is being returned in milliseconds. Do I have to divide and multiply to get it converted into hours/seconds/minutes.. or is it possible to do the same with some format specifier?
Thanks for your reply..
Regards,
Nijeesh.
 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nijeesh,
I would say just divide. I don't know of a format specifier off of the top of my head.
You can refer to this article and grab his code to convert to the larger time units:
http://www.javaworld.com/javaworld/jw-03-2001/jw-0330-time-p2.html
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi - If you use the long (timeDifference) in the above code like:
Date d = new Date(timeDifference);
then d will be some number of months, days, hours, minutes, seconds, .... since Jan 1, 1970. Ignore the year, and just look at the other fields for the elapsed time.
Alternatively, there is an open source implementation of ISO8601 dates being done on sourceforge (the Joda project). Date arithmetic is reasonably straight forward. You might take a look at that.
HTH, Guy
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic