0
5.7kviews
Write a program to find the current date and time using JSP..

Mumbai University > information technology > sem 4> Web Programming

Marks: 5M

Year : Dec16

1 Answer
0
772views

Getting Current Date & Time

This is very easy to get current date and time in JSP program. You can use a simple Date object with toString() method to print current date and time as follows:

<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<html>
<head>
<title>Display Current Date & Time</title>
</head>
<body>
<center>
<h1>Display Current Date & Time</h1>
</center>
<%
   Date date = new Date();
   out.print( "<h2 align=\"center\">" +date.toString()+"</h2>");
%>
</body>
</html>
Please log in to add an answer.