Date in JSP

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


 
Ads

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

Share on Google+Share on Google+

Date in JSP

Posted on: February 7, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Date in JSP   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads