Fmt: formatDate and timeZone
I have fields in Mysql database typed by datetime.
I store, for example, a payment date with the following Java code:
payment.setCreatedOn(new Date(System.currentTimeMillis()));
In my view layer, I am using fmt: formatDate to format dates:
<fmt:formatDate value="${payment.createdOn}" pattern="EEE, dd MMM yyyy HH:mm:ss"/>
My server is in London and my app users are in Vienna. Time display is delayed probably due to different time zones. I can use the TimeZone parameter in fmt: formatDate.
timeZone: The time zone in which the formatted time is represented.
After searching on Google, I think the Europe / Vienna value is valid for the timeZone parameter.
Does anyone know if there is a list of valid timeZone strings?
a source to share
Sergio - I'm sure you found him a long time ago ...
This is the home page for the Olson database, or "zoneinfo", which is the definitive source of TZ information.
And here's a nice wiki for browsing zones.
a source to share
You need to use international time (UTC / Zulu) to add the next time using the schedule, for example "GMT + 1". See this example.
Place this parameter as an argument on your server to set the time to use UTC, in this case for tomcat:
-Duser.timezone = "UTC"
/* Java */
@RequestMapping(value = "/web", method = { RequestMethod.POST, RequestMethod.GET })
public String web(Model model, HttpSession session, Locale locale) {
Date today = new Date();
model.addAttribute("currentTime", today);
model.addAttribute("timezone", "GMT+1");
return "web";
}
To show the date, select the desired template (properties)
/* JSP web */
<fmt:timeZone value="${timezone}">
<spring:message code="date_format_dateMin" var="pattern"/>
<fmt:formatDate value="${currentTime}" timeZone="${timezone}" pattern="${pattern}" var="searchFormated" />
<span class="innerLabel">${searchFormated}</span>
</fmt:timeZone>
/* Properties */
date_format_dateMin=yyyy/MM/dd HH:mm
date_format=yyyy/MM/dd HH:mm:ss
date_format2=yyyy/MM/dd
date_format3_js=yy/mm/dd
date_format4_time=HH:mm
date_format4=dd/MM/yyyy HH:mm:ss
a source to share