I have written a program for getting the system date.
<%@page import="java.util.*,java.text.*"%>
<html>
<body>
<p> </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"> Date Example</font></td>
</tr>
<tr>
<td width="100%"><b> Current Date
and time is: <font color="#FF0000">
<%
DateFormat formatter = new SimpleDateFormat("DD-MON-YY");
String date = formatter.format(new java.util.Date());
%>
<%=date%>
</font></b></td>
</tr>
</table>
</center>
</div>
</body>
< /html>
I am getting an error. Please let me know how to convert the system date to dd-MMM-YY format.
A pattern of special characters is used to specify the format of the date. This example demonstrates some of the characters. For a complete listing, see the javadoc documentation for the SimpleDateFormat class.
Note: This example formats dates using the default locale (which, in the author’s case, is Locale.ENGLISH). If the example is run in a different locale, the text (e.g., month names) will not be the same.
Some examples: