• 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

DATE SUBRACTION

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks

I have two columns in database which has date and time.
I am taking using result set two different dates , suppose d1 and d2 as getString method.
Now i want to subtract these two dates and store the result as a string.
The dates subtracted should have the remaining days as hours converted and added to the subtracted hours.

For example , 12/01/2008 08:08:01 and 11/01/2008 08:08:01 are there means on subtracting the time we get 12 hours difference , then the day adds on to 1 day and i want that hours to be added along with this and i want the result in hours min and sec.

Kindly help me in this problem.
Thanks in advance.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Venkat and welcome to Javaranch!

Please search this forum for this question, it has been answered many times before .

In short, look at the Date, Calendar and Timezone APIs, you'll quickly find what you are looking for there...
 
venkat warlu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i searched the forum but no proper answer. I am a beginner and i want the code to be explained properly. please help me out in this.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, to help you start on your way, look at the Calendar methods, in particular the add method.
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic