Enter your email address:

Delivered by FeedBurner


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compare current time with database retrieved time in jsp
12-19-2011, 05:17 PM (This post was last modified: 12-19-2011 05:18 PM by rajasri.)
Post: #1
Lightbulb compare current time with database retrieved time in jsp
This is the viewer question asked by smiten.
how can i compare the database stored time to current time?
I had previously written an article about In order to view links, you must have to reply to this thread. Now just make some changes retrieve the database time and split the values of hours,minutes,seconds and finally check the values to get the real time.

<%@ page language="java" import="java.util.*,java.sql.*,java.math.*,java.text.SimpleDateFormat"pageEncoding="ISO-8859-1"%>
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
String date=dateFormat.format(calendar.getTime());
String c="select * from time";
st1=con.createStatement();
ResultSet rs1=st1.executeQuery©;
while(rs1.next())
{
dbdate=rs1.getString(5);
}
String[] exdate=a.split("-");
int dbdate=Integer.parseInt(dbexdate[0]);
String[] currentdate=date.split("-");
int cdate=Integer.parseInt(currentdate[0]);

if(dbenddate[1].equals(currentdate[1]))
{
diff=dbdate-cdate;
}
out.println(diff);
%>



Have a doubt leave a comment.

Happy coding
Find all posts by this user
Add Thank You Quote this message in a reply
Advertise here or at any positions around our site send a mail to info@walkinsforum.com
Post Reply 


[-]
Share/Bookmark (Show All)
Facebook Linkedin Technorati Twitter Digg MySpace Delicious

Possibly Related Threads...
Thread: Author Replies Views: Last Post
Sad how to import a csv file values in to database using jsp rajasri 2 1,211 02-20-2012 12:17 PM
Last Post: rajesh2407
Shocked Finding created/modified time of files in a folder rajasri 0 100 12-19-2011 05:50 PM
Last Post: rajasri
Thumbs Up Display combo box value/Database value on same JSP page rajasri 0 325 12-19-2011 04:57 PM
Last Post: rajasri
Its My Birthday! Display database value in jsp page rajasri 0 609 12-14-2011 11:43 AM
Last Post: rajasri
Video Display current time and date in your Jsp page rajasri 0 957 12-12-2011 11:56 PM
Last Post: rajasri
Big Grin Retrieve database table values in loop using jsp rajasri 0 694 12-12-2011 11:24 PM
Last Post: rajasri
Bug Print current time using java in jsp page rajasri 0 619 12-12-2011 11:20 PM
Last Post: rajasri

Forum Jump:


User(s) browsing this thread: 1 Guest(s)