Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a date as ISO8601 with JSTL?

Something like?

<fmt:formatDate value="${event.starttime}" type="both"/>
like image 872
Sergio del Amo Avatar asked Sep 06 '09 16:09

Sergio del Amo


People also ask

What is the date format according to ISO 8601?

ISO 8601 represents date and time by starting with the year, followed by the month, the day, the hour, the minutes, seconds and milliseconds. For example, 2020-07-10 15:00:00.000, represents the 10th of July 2020 at 3 p.m. (in local time as there is no time zone offset specified—more on that below).

What time zone is ISO 8601?

Universal Coordinate Time is the time at the zero meridian, near Greenwich, England. UTC is a datetime value that uses the ISO 8601 basic form yyyymmddT hhmmss+|– hhmm or the ISO 8601 extended form yyyy-mm-ddT hh:mm:ss+|– hh:mm.

Who uses ISO 8601?

ISO 8601 can be used by anyone who wants to use a standardized way of presenting: Date. Time of day. Coordinated Universal Time (UTC)


1 Answers

It is not possible AFAIK. You can use the pattern attribute:

<fmt:formatDate pattern="yyyy-MM-dd'T'HH:mm:ssz" value="${event.starttime}" />

But there is not a pattern to generate ISO8601 without post-processing. You have to cook your date in the server side and show it in your view.

You might find Joda-Time library useful, as well as some blog posts like:

  • http://www.coderanch.com/t/376612/Java-General/java/SimpleDateFormat-ISO
  • http://www.dynamicobjects.com/d2r/archives/003057.html
  • http://developer.marklogic.com/howto/tutorials/2004-09-dates.xqy
like image 139
Guido Avatar answered Sep 20 '22 02:09

Guido