[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Date Format

hi everbody
my problem very simple but i don't anything about it
i take last_date coloum my query
(aaa.getString("last_date"))
and we use oracle so this format is 2000-01-01 00:00:00.0
iwant to use format dd/mm/yyyy
how do i do
Can you help me
Thankx
0
skychan
Asked:
skychan
  • 4
1 Solution
 
koppchaCommented:
SimpleDateFormat sdf = new SimpleDateFormat(dd/MM/yyyy);
Date d = sdf.parse(aaa.getString("last_date")) ;
System.out.println(sdf.format(d));
0
 
Jim CakalicSenior Developer/ArchitectCommented:
Hi,

I assume (given the topic) that this is in a JSP. If so, you could use the JSTL formatDate tag:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
...
    <jsp:useBean id="now" class="java.util.Date" />
    Date: <fmt:formatDate value="${now}" pattern="MM/dd/yyyy" />

Regards,
Jim Cakalic
0
 
koppchaCommented:
To Print on JSP you can do
<%
SimpleDateFormat sdf = new SimpleDateFormat(dd/MM/yyyy);
Date d = sdf.parse(aaa.getString("last_date")) ;
out.println(sdf.format(d));
%>
0
 
koppchaCommented:
you can use
<%= ....%> as well
0
 
koppchaCommented:
Just wondering why C Grade ?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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