0

我在 Mysql 数据库中有字段类型为datetime

例如,我使用下一个 Java 代码存储付款日期:

payment.setCreatedOn(new Date(System.currentTimeMillis())); 

在我的视图层中,我使用fmt:formatDate来格式化日期:

<fmt:formatDate value="${payment.createdOn}" pattern="EEE, dd MMM yyyy HH:mm:ss"/> 

我的服务器在伦敦,我的应用程序的用户在维也纳。时间显示延迟可能是因为不同的时区。我可以在 fmt:formatDate 中使用timeZone参数。

timeZone:表示格式化时间的时区。

在谷歌搜索后,我认为Europe/Vienna的值对timeZone参数有效。

有谁知道是否有任何有效时区字符串的列表?

4

3 回答 3

1

塞尔吉奥 - 我敢肯定你早​​就找到了它......

这是Olson 数据库或“zoneinfo”的主页,它是 TZ 信息的权威来源。

这是一个不错的 wiki用于浏览区域。

于 2009-10-18T14:18:59.783 回答
0

这是 IBM JDK 的列表,有点过时但有完整列表:

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

于 2011-04-15T01:18:41.673 回答
0

您需要使用国际时间(UTC/Zulu)添加以下调度客户端时间使用,例如“GMT+1”。请参阅此示例。

将此参数作为参数放在您的服务器中以设置 UTC 时间使用,在这种情况下适用于 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";
}

要显示日期,请选择您想要的模式(属性)

/* 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
于 2014-05-08T08:00:32.417 回答