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 how to display time in jspNow 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(c);
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




