• Post Reply Bookmark Topic Watch Topic
  • New Topic

time difference  RSS feed

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • 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 is greater than 15 minutes.I am having both the times in yy:mm d 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 minutes now?

Thanks.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EaseUp. You won't get answers any faster for writing urgent.

Please check for spelling; what you posted isn't � hour out, but more like 3 weeks. Check the ResultSet#getString() method; I don' tthink it returns what you think it returns.
 
Jan Cumps
Bartender
Posts: 2632
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The trick is to not convert the values to a text string.
They make it d

Pseudocode example returns difference in miliseconds (untested):If the result contains more milliseconds than fit in 15 minutes, you know that the difference between these two times is more than 15 minutes.

Regards, Jan
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you jan.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!