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?

0


a source to share


3 answers


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.

+1


a source


Here's a list for the IBM JDK, a little outdated but complete:



http://publib.boulder.ibm.com/infocenter/wsdoc400/v6r0/index.jsp?topic=/com.ibm.websphere.iseries.doc/info/ae/ae/adrtzval.htm

0


a source


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

      

0


a source







All Articles