You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "Narayan, Anand" <AN...@e-gatematrix.com> on 2003/07/28 19:26:35 UTC

Formatting timestamps retrieved in a sql result set

After executing a query I want to format any date and time values
using a custom pattern before displaying them.
How would I accomplish this?

Heres the query I am executing in my JSP:
<sql:query var="results" scope="session">
SELECT parameter.PARM_ID "id",
parameter.LAST_CHANGE_DATE "updateTime",
parameter.LAST_CHANGE_BY "updateUser"
FROM PARAMETER parameter
ORDER BY parameter.LAST_CHANGE_DATE asc,parameter.LAST_CHANGE_BY asc
</sql:query>

Here is part of the display code. I want to format ${row.updateTime}
to a different date time format.   THANKS

<c:forEach var="row" items="${results.rows}">
...
...
...
<tr class=<c:out value="${rowClass}"/> >
  <td class="resultDataCellCenter">&nbsp;<c:out value="${row.id}" /></td>
  <td class="resultDataCell">&nbsp;<c:out value="${row.updateTime}" /></td>
  <td class="resultDataCell">&nbsp;<c:out value="${row.updateUser}" /></td>
</tr>
</c:forEach>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Formatting timestamps retrieved in a sql result set

Posted by Felipe Leme <t5...@sneakemail.com>.
On Monday 28 July 2003 02:26 pm, Narayan, Anand ANarayan-at-e-gatematrix.com 
|jakarta| wrote:
> After executing a query I want to format any date and time values
> using a custom pattern before displaying them.
> How would I accomplish this?

You could use the <fmt:formatDate> tag, using the pattern attribute. Something 
like this:

  <fmt:formatDate value="${row.updateTime}"  pattern="MM/dd/yyyy HH:mm"/>

Felipe

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org