Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

difference between 2 times  RSS feed

 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!