Date in JSP
Posted on: February 7, 2008 at 12:00 AM
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:

Related Tags for Date in JSP:
cjspideclassdatepropertiesattributesimportsedpageportnameattributethisidportingpackagejsforietosseeilitdirectiverteimportingcanusepeimceinasmtrsidsidecajpackclesdiragenamedmeproacktiewhichsrectspsoeedirectessatpackisirhallivproperandccrtropettssrithaccesshatpropprndono


More Tutorials from this section

Ask Questions?    Discuss: Date in JSP   View All Comments

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.