• Post Reply Bookmark Topic Watch Topic
  • New Topic

BIG PROBLEM ON DATE  RSS feed

 
Mehak Daani
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.....
I have this big confusion .... i have 2 dates of the format yyyy-mm-dd hh:mm:ss ........ now when i subtract thses dates the value that i get are really gibbrish .....
like when i subtract 2003-10-22 12:34:40and this 2003-10-29 13:15:12 the difference that i get is "7008072" ........??? y doesn't it give me 1 day..!!!
what i want the dates to do is ...
when i subtract suppose (2003-10-20 10:10:05 - 2003-10-20 08:10:05) ...
the result it should give me is
02:00:00 .... i.e. 2hrs and 0 minutes ..... and if the date is
(2003-10-25 10:10:05 - 2003-10-20 08:10:05) ...
then the result that it should give me is
05 02:00:00 ... means the time taken is 5 days and 2hrs....!!!
Please some one help me out on this one.... plz plz...!!!
Thanx
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
show us how you are doing it. ie post code.
without knowing more about what you are doing i would guess that what you are getting is the difference in milliseconds. you should be able to format this using various java api classes.
there are lots of tutorials on the web about using java dates and calendars etc
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Mehak!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
Secondly, THERE'S NO NEED TO SHOUT. Please lose the caps-locks.
And thirdly, this has nothing to do with JSP so I'm moving it to Java in General (Intermediate).
Thanks!
bear
JSP Fourm Bartender
[ November 02, 2003: Message edited by: Bear Bibeault ]
 
Mehak Daani
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok ... i'm posting my code ... coz nothing is to my avail... please some one help me out on this one ...!!!
Value of AttendedTo from database = 2003-10-29 15:15:12
Value of time from database =2003-10-22 12:34:40
ResultSet call_details2 = sel_name2.executeQuery(" SELECT AttendedTo -time )diffdate FROM complaints where callid = '11' ") ;
The difference that is calculated by the query is "7008072"
Then i'm taking this value to a string as getDate is not working ... it gives an error that cannot parse date ...!!!
String dd = call_details2.getString("diffdate");
My Question is how can i get the difference between the two dates in a format of "yyyy-mm-dd hh:mm:ss"
Please some one help me out on this one..!!!
Thanx in Advance..!!

I have tried to do the above in the following manner but it's not of my requirement ...
Date Attendedto = call_details.getDate("AttendedTo");
Date time - call_details.getDate("time");
The problem with above is that it returns me only the date i.e.2003-10-22 .... but i also want the time ... and i want both the date and time for calculation...!!!
Any and all ideas are welcomed ...
 
Mehak Daani
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can also some one tell me ... if i have a long date ...like 2003-10-22 12:34:40 and this 2003-10-29 15:15:12...
ow can i extract just the time out of it ... and then make calulation only on the time of both the dates ..and not the dates itself ... ... .
like (15:15:12 - 12:34:40 ).....!!!
All help is appreciated ....... and plz try and include sample code ...!!!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Mehak",
You have been asked to change your display name to comply to the JavaRanch naming policy. Please see Bear's post above.
Please change you display name soon, since you now have 13 posts and accounts with invalid display names get deleted without warning
thanks,
Dave.
 
Mehak Daani
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No replies yet ....... ???
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!