Programming Tutorials

(追記) (追記ここまで)

JSP Program to display Date

By: aathishankaran in JSP Tutorials on 2007年02月13日 [フレーム]

This program shows you how to create a simple dynamic JSP page that prints the current date and time.

So the following code accomplishes this:

<%@page contentType="text/html" import="java.util.*" %>
<!-- http://www.java-samples.com/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 main concept in this program 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() %>



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments (2)

Sort By
Topic: JSP Program to display Date
5/5 (1)
Avatar
New
shivanaik
Avatar
1
0
0
May 2023
First Poster
shivanaiksays...

hi i want to show the Calendar in text field when the user enter into that text box please help me or else mail me

0
0
Avatar
New
Morgan
Avatar
6
0
0
May 2023
Morgansays...

You can show a calendar using JavaScript within your JSP check this Show calendar within JSP using JQuery

0
0
Share a link to this comment
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /