I have been working on this for two days solid now. I have gone through numerous posts here but they are not much help to me.
I need to take two dates from a user and calculate the number of days between them. I understand that JODA-time is best and that is not an option ( I am sure the point of this exercise is to go through pain...). I am not worried about leap year or daylight savings time as of yet. I take things in small steps. I have included the code for getting the input but I have not been able to form the syntax correctly to compare the two inputs. Any nudge in the correct direction is appreciated.
<%@page import="java.util.Calendar" %>
<%@page contentType="text/html" import="java.util.*" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Date Comarision</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script>
$(function() {
$( ".datepicker" ).datepicker();
});
</script>
</head>
<body>
<form action="Calculate.jsp" method="post">
<p>First Date: <input type="text" name="firstdate" class="datepicker" /></p>
<p>Second Date: <input type="text" name="seconddate" class="datepicker" /></p>
<input type="submit" value="Calculate">
</form>
</body>
</html>
Latest for comparing (not pretty):
<%@page import="sun.util.calendar.LocalGregorianCalendar.Date"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Calculate</title>
</head>
<body>
<h1>Calculate</h1>
<center>
<!--This is where the issues start. I know I can't be forming this correctly: -->
<%
int Date1= Date.parseInt(request.getParameter("firstdate"));
int Date2= Date.parseInt(request.getParameter("seconddate"));
%>
<BR>
<%
out.println("----- " )+Date1.compareTo(Date2)+("----");
%>
</center>
</body>
</html>