0
<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>

i need to print the date in the format dd//mm/yyyy how can i get it

jin
  • 3
  • 3

2 Answers2

1

You can use a SimpleDateFormat to format your output:

SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
System.out.println(dateFormat.format(dateFormat.parse(<your date object>)));
Hemang
  • 390
  • 3
  • 20
0

Instead of

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

use

<%= new SimpleDateFormat("dd/MM/yyyy").format(new java.util.Date())%>

Note : You need to import SimpleDateFormat in your jsp

<%@ page import="java.text.SimpleDateFormat" %>
RockAndRoll
  • 2,247
  • 2
  • 16
  • 35
  • How i can connect ms sql server in jsp ? I have add jar file for ms sql. but shows an error java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1856) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705) Please help – jin Dec 31 '15 at 10:09
  • http://stackoverflow.com/questions/22253551/classpath-set-but-java-lang-classnotfoundexception-com-microsoft-sqlserver-jd it might help. – RockAndRoll Dec 31 '15 at 11:29