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 Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

difference between 2 times

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

please tell me the APIs used to find the differences b/w 2 times.That is,

start time:- 10:12:35
end time :- 10:12:48

How to do it?

or

Please explain it with a code!
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mythily,
i am not sure if we be have direct way of fining time differnce. Well as for i know you have java.util.GregorianCalendar Class which helps to achive what you intend too...
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
depends on your requirements...

if we talk about short intervalls of minutes or hours or so, just get the difference of the millis and recalculate to seconds, minutes, whatever

if we talk about intervalls of days, months, years (leap years!) take joda-time. (just google it)

concerning code examples: the philosophy of this forum is more to help learning than to provide solutions. so, better show us what you did already, and then get help from many friendly users here... :-)

best regards,
jan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!