Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 659
  • Last Modified:

Data format YYYY-MM-DD

Hi, I am tring to insert a date in my JSP page. But what I can do is only <%=new java.util.Date()%> which result in a long string (like Mon Mar 03 00:09:54 PST 2003).

I wonder if I can have something short like YYYY-MM-DD or DD-MM-YYYY whatever.

Many thanks.
0
joett
Asked:
joett
  • 3
  • 2
1 Solution
 
objectsCommented:
<%
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyy-MM-dd");
%>
<%= df.format(new java.util.Date()) %>
0
 
objectsCommented:
woops, should be:

<%
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
%>
<%= df.format(new java.util.Date()) %>
0
 
joettAuthor Commented:
Is it possible to add a week day there? like Monday, Tuesday?

thanks.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
thanassisCommented:
try this:
<%
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("EEE, MMM d, yyyy");
%>
<%= df.format(new java.util.Date()) %>


0
 
objectsCommented:
I answer your original question, and you go and accept someone elses comment???
0
 
joettAuthor Commented:
hi, objects, i am sorry. i would like to spilt my points if i could. but thanasis did solved my problem.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now