Anil,

Thanks! You're absolutely right about this. When I tried explicitly converting the Timestamp to a Date, it just printed the date out using Date.toString(), which is more user-friendly but still can't be patterned with the formatDate tag.

Adding the statement to set the locale works like a charm.

-emily

Anil Gangolli wrote:

My guess is this is happening because JSTL is not finding the locale defined and is resorting to the toString() method.

As a simple test, please try this:

(1) Early in the main.jsp (before first use of fmt:formatDate) use <fmt:setLocale value="en_US"/> (2) Use <fmt:formatDate value="${post.pubTime}" type="date" dateStyle="full" pattern="MMMM d, yyyy"/>

n.b.: You may need to clear out Tomcat's work directory for your webapp (work/Catalina/localhost/<webappname>) to get rid of prior compiled versions. You probably need to restart Tomcat to get it to reload the compile JSP's class.

If this works for you let us know; it means the JSP is not getting the locale set properly and that would be a bug. I'm not sure if it is in current versions or not.

--a.




----- Original Message ----- From: "Emily Lynema" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, January 10, 2007 2:16 PM
Subject: Using jstl <fmt:formatDate> tag


I'm trying to reformat the post date/times that appear on our roller main page.

I'm still on roller 2.1, so I apologize for being a bit behind. We are running in Apache Tomcat 5.5.17 with Java 1.5.

Here's the original code in the main.jsp for each 'recent post':

<fmt:formatDate value="${post.pubTime}" type="both" dateStyle="medium" timeStyle="medium" />

which produces a display like this:

2007-01-05 10:06:54.0

I would like it to display something more like 'January 5, 2007' without the timestamp. But no matter how I fiddle with the <fmt:formatDate /> options, I can't get anything to change.

For example, this code:

<fmt:formatDate value="${post.pubTime}" type="date" dateStyle="full" />

continues to produce:

2007-01-05 10:06:54.0

The formatDate tag, as far as I can find, seems to be expecting a java.util.Date, and the WeblogEntryData.pubTime seems to be a java.sql.Timestamp, so I'm wondering if there are incompatabilities there. Any advice would be appreciated!

-emily
--
Emily Lynema
Systems Librarian for Digital Projects
Information Technology, NCSU Libraries
919-513-8031
[EMAIL PROTECTED]



--
Emily Lynema
Systems Librarian for Digital Projects
Information Technology, NCSU Libraries
919-513-8031
[EMAIL PROTECTED]

Reply via email to