This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

BIG PROBLEM ON DATE

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...!!!
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No replies yet ....... ???
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic