• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Time Difference

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
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
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.
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
read my previous post, you will possibly get your answer.

Shailesh
 
reply
    Bookmark Topic Watch Topic
  • New Topic