Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Time Difference

 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
read my previous post, you will possibly get your answer.

Shailesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic