Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Date in JSP

Advertisement
To print a Date in JSP firstly we are importing a class named java.util.Date of the package java.util.

Date in JSP

        

To print a Date in JSP firstly we are importing a class named java.util.Date of the package java.util. This package is imported in the jsp page so that the Date class and its properties can accessed in the JSP page. To import a package we need to use page directive inside which we will use its one of its attributes named import which is used for importing the class and package.

To print the current date we are using a expression directive in which we are creating a object of Date class. We have used toString() method to convert Date type to String.

 

The output of the program is given below:

 

 

<%@ page import ="java.util.Date" %>
<html>
	<head>
		<title>The current date is</title>
	</head>
		<body>
		<font size = 6 color = "#FF0000">current date is 
                 :<%= new Date().toString()%></font>
		</body>
</html>

The output of the program is given below:

Download this example:

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 7, 2008

Ask Questions?    Discuss: Date in JSP   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com