<%@ page language="java" import="java.sql.*" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<html>
<head>
<title>Display Current Date & Time</title>
</head>
<body>
<center><h1>Display Current Date & Time</h1></center>
<%
Date currentDate = new Date();
out.println("Current Date is:"+currentDate);
String txtDate = new SimpleDateFormat("yyyy-mm-dd").format(currentDate);
out.println("Current Date in text format is:"+txtDate);
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://retail:3306/rs","RS","orbisindia");
Statement stmt1 = conn.createStatement();
ResultSet rs1 = stmt1.executeQuery("select * from retail_inventory") ;
while (rs1.next()){
out.println(txtDate.toString());
out.println((rs1.getString(6).toString()));
out.println((txtDate.toString()) - (rs1.getString(6).toString()) );
%><br><%
}
conn.close();
catch(Exception e){
out.println(e);
}%>
</body>
</html>