jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes Time Difference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Time Difference" Watch "Time Difference" New topic
Author

Time Difference

R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,

I need to check the difference between the time in database and system time.I am having both the times in yy:mm:dd hh:mm:ss format.please reply me how to do this .very urgent.I am getting both the time in string like



String calledtime=rs.getString("calledtime");
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss") ;
String currenttime = formatter.format (new Date()) ;




I am getting the output printed as
2008-05-02 16:52:17
2008-05-20 15:10:44

How can i check particularly the seconds now?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60781
    
  65

Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Treat the date as Date object not the string. Invoke the method getTime() on the date which will return a long value in milliseconds. substract and get the defference between database and system time.




Shailesh



Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,

Thanks for your response. I need to check the difference between the time in database and system time.I am having both the times in yy:mm:dd hh:mm:ss format.please reply me how to do this .very urgent.I am getting both the time in string like

String calledtime=rs.getString("calledtime");
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss") ;
String currenttime = formatter.format (new Date()) ;




I am getting the output printed as
2008-05-02 16:52:17
2008-05-20 15:10:44


I need this output like this 00:00:00

00:00:01
00:00:02
00:00:03
00:00:04
00:00:05


Thanks.

Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

read my previous post, you will possibly get your answer.

Shailesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Time Difference
 
Similar Threads
Time Difference
gps week/seconds conversion
Time format in Java
how to change the date,Time format after accessing it from the database
time difference