|
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
|
|||
|
|||
|
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
|
|||
Advertise here or at any positions around our site send a mail to info@walkinsforum.com
|
« Next Oldest | Next Newest »
|
![]() |
|||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies | Views: | Last Post | |
| 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 |
|
| Finding created/modified time of files in a folder | rajasri | 0 | 100 |
12-19-2011 05:50 PM Last Post: rajasri |
|
| Display combo box value/Database value on same JSP page | rajasri | 0 | 325 |
12-19-2011 04:57 PM Last Post: rajasri |
|
| Display database value in jsp page | rajasri | 0 | 609 |
12-14-2011 11:43 AM Last Post: rajasri |
|
| Display current time and date in your Jsp page | rajasri | 0 | 957 |
12-12-2011 11:56 PM Last Post: rajasri |
|
| Retrieve database table values in loop using jsp | rajasri | 0 | 694 |
12-12-2011 11:24 PM Last Post: rajasri |
|
| Print current time using java in jsp page | rajasri | 0 | 619 |
12-12-2011 11:20 PM Last Post: rajasri |
|
User(s) browsing this thread: 1 Guest(s)






![[-]](images/royal_red/collapse.gif)






