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
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
Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
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 ]
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 ...
posted 15 years ago
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 ...!!!
"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.