Home Jsp JSP date example

Related Tutorials


 
 

Share on Google+Share on Google+

JSP date example

Advertisement
JSP date example JSP Date Example Till now you learned about the JSP syntax, now I will show you how to create a simple dynamic JSP page that prints the current date and time. So the following code accomplish this: <%@page contentType="text/html"

JSP date example

        

Till now you learned about the JSP syntax, now I will show you how to create a simple dynamic JSP page that prints the current date and time. So the following code accomplish this:

 

 

 

 

 

<%@page contentType="text/html" import="java.util.*" %>

<!--

http://www.roseindia.net/jsp

-->

<html>
<body>
<p>
&nbsp;</p>
<div align=
"center">
<center>
<table border=
"0" cellpadding="0" cellspacing
=
"0" width="460" bgcolor="#EEFFCA">

<tr>
<td width=
"100%"><font size="6" color
=
"#008000">&nbsp;Date Example</font></td>

</tr>
<tr>
<td width=
"100%"><b>&nbsp;Current Date 
and time is:&nbsp;
<font color="#FF0000">


<%= new java.util.Date() %>
</font></b></td>
</tr>
</table>
</center>
</div>

</body>
</html>

The heart of this example is Date() function of the java.util package which returns the current data and time. 

In the JSP Declaratives 

<%@page contentType="text/html" import="java.util.*" %>

we are importing the java.util package and following JSP Expression code 

<%= new java.util.Date() %>

prints the current date on the page.

  Execute the example.
  Download the  code

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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: January 30, 2005

Related Tutorials

Discuss: JSP date example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
Ravi Kant Soni
September 22, 2011
Server-Side date Using Java

How to find the serverside date. Bec if i will change the client's machine date , then that date will display which should not be happen . Plaese reply me as soon as possible.
venkat
January 29, 2014
thanks

really helpful thanks
DMCA.com