• Post Reply Bookmark Topic Watch Topic
  • New Topic

DATE SUBRACTION  RSS feed

 
venkat warlu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, to help you start on your way, look at the Calendar methods, in particular the add method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!