Dear Sir,
I want to get the difference of date/time captured in mysql and present date/time in jsp.
I am using the following code to get, but its getting difference only in hrs, i used split strings in jsp for that, can u please help me in this code, i have to get difference in min and sec also. - <%@ page import="java.sql.*,java.text.SimpleDateFormat" %>
-
-
<%! int x; %>
-
-
<%
-
-
String EmployeeId;// = request.getParameter("EmployeeId");
-
EmployeeId = session.getAttribute("ssnEmployeeId").toString();
-
-
x = 0;
-
-
-
Class.forName("com.mysql.jdbc.Driver").newInstance();
-
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/aams","root","root");
-
Statement st = conn.createStatement();
-
ResultSet rs = st.executeQuery("select employeename from admin where employeeid='"+EmployeeId+"' and flag = 0");
-
-
if(rs.next()){
-
//String employeeid=(String) session.getAttribute("employeeid");
-
-
//if(employeeid.equals(employeeid) == true ){
-
-
// session.setAttribute("employeeid",employeeid);
-
-
//System.out.println("Reached");
-
rs = st.executeQuery("select intime from admin where employeeid = '"+ EmployeeId+ "' and flag = 0 ");
-
rs.next();
-
-
java.util.Date now = new java.util.Date();
-
String DATE_FORMAT = "dd-hh";
-
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-
-
String strDateNew = sdf.format(now) ;
-
-
-
-
String s3 = rs.getString(1);
-
String [] temp = null;
-
temp = s3.split("-");
-
-
-
String strDate = temp[2], strTime = temp[3];
-
//System.err.println("Reached");
-
-
s3 = strDateNew;
-
temp = null;
-
temp = s3.split("-");
-
int curtime, oldtime;
-
curtime = Integer.parseInt(temp[1]);
-
oldtime = Integer.parseInt(strTime);
-
-
System.out.println("Current Time" + curtime);
-
System.out.println("Old Time" + oldtime);
-
System.out.println("Current Date" + strDate);
-
-
if(curtime<oldtime)
-
{
-
curtime=curtime+12;
-
}
-
-
-
int diff = curtime - oldtime;
-
-
if(strDate.equals(temp[0]) == false || diff >=8)
-
{
-
%>
-
<jsp:forward page="checkout.jsp" />
-
<%
-
}
-
else{
-
int total=diff;
-
diff = 8-diff;
-
session.setAttribute("ssnTimeDifference", diff);
-
session.setAttribute("totaltime", total);
-
response.sendRedirect("warning.jsp");
-
}
-
}
-
else{
-
%>
-
-
<jsp:forward page="CheckIn.jsp" />
-
<%
-
}
-
-
%>
Please help me in this code to get both min and sec...
0 1746 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: zaceti |
last post by:
I'm new to MySQL and I am having a problem selecting the highest
valued date/time for a particular day. Here is the table structure:
+--------------+-----------------+-----+----+--------+--------------+
| Field | Type | Null| Key| Default|Extra |
+--------------+-----------------+-----+----+--------+--------------+
| id | int(10) unsigned| | PRI| NULL |auto_increment|
| timestamp | datetime ...
|
by: Gord |
last post by:
Many scripts and calendars call client side system time in order to
make presentations.
However, the client's time may be improperly set, if set at all,
and/or the relevant time may be from another time zone.
It would be of great value if the time of some central source could be
drawn, in the form of a ".js" file, into the script to avoid
dependence on the client's date/time.
|
by: Noozer |
last post by:
I have a textbox on one of my forms that is used to accept a time from the
user. I need to write this value to a database to trigger an event later on.
What I'd like to know is...
Are there any functions in javascript that can convert different time
formats to a known format (24 hour clock)... 5pm -> 17:00 or 5:00 to 05:00,
etc. ???
Assuming that I get the input into a 24 hour format, how can I create a full
|
by: Chris |
last post by:
Can someone point me the right way? I'm trying to use the date/time
extensions but with little luck. Here's what I've got:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times" >
<xsl:template match="/" >
date-time: <xsl:value-of select="date:date-time()"/>
|
by: mcmcalex |
last post by:
is there an easy way to make a date/time field (in Access) convert to a
date field (in Excel) when using ms-query? I'm pretty good with xl,
but new to access, so apologies if this is covered on p1 of the user's
guide (my _quick_ search in this forum didn't find an answer to my
question).
tia
mcalex
| |
by: Miguel Dias Moura |
last post by:
Hello,
i am just finishing a web site in ASP.net / VB using Dreamweaver MX 2004 and
in all the pages i use the date/time format as follows:
Date: DD-MM-YYYY
Time: HH-MM (24 hours)
Anyway, everything works fine when testing in my computer. However, when i
uploaded the web site to my hosting space in the date/time appears as
|
by: Miguel Dias Moura |
last post by:
Hello,
i am just finishing a web site in ASP.net / VB using Dreamweaver MX 2004 and
in all the pages i use the date/time format as follows:
Date: DD-MM-YYYY
Time: HH-MM (24 hours)
Anyway, everything works fine when testing in my computer. However, when i
uploaded the web site to my hosting space in the date/time appears as
|
by: walterbyrd |
last post by:
My MySQL table has a field that is set as type "date." I need to get
today's date, and insert it into that field. The default for that MySQL
field is 2006-00-00.
I know about the date() function. I have tried date("Y-m-d") and
date("U"), neither worked. The date field was just filed with all
zeros.
Can anybody point me in the right direction?
|
by: orajat |
last post by:
hi,
how do i calculate difference in time in seconds (00:09:05 - 00:09:00 = 300) where start time being a field and the difference in time is calculated in AHT field, ie last record minus previous record. this should be a continious excercise in ms access database table
|
by: dizzydangler |
last post by:
Just a quick question...I'm running an MS Access 2007 db that tracks appointments in a single table. Date and time are entered as separate fields in short date (mm/dd/yyyy) and short time (hh:mm) format. I've been running queries by date alone, which has been working, but there are times when I have to run queries based on times as well. (e.g. return all apointments that occurred after 1:00 PM on 12/15/2009 and before 1:00 PM on 12/22/2009). ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |