简体   繁体   中英

AppEngine java.util.Date with Timezone in Struts2

Im using Struts2 in Google App Engine.

I have java.util.Date property in an entity.

private Date date = null;

public Date getDate() {
    return date;
}
public void setDate(Date date) {
    this.date = date;
}

I want to display the date with our timezone which is GMT+8 . So I have the following in my view:

<s:date name="dateAdded" format="MMM. d, yyyy / hh:mm a" timezone="GMT+08:00" />

But it is not displaying the correct time for GMT+8 .

Anybody can explain the behaviour? How to display it in GMT+8 ?

I think you need to use the timezone name:

      <s:date name="dateAdded" format="MMM. d, yyyy / hh:mm a" timezone="PST" />

or

      <s:date name="dateAdded" format="MMM. d, yyyy / hh:mm a" 
                                               timezone="America/Los_Angeles" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM