开发者

How to customize the Struts Json Plugin Date format for a global scope

开发者 https://www.devze.com 2023-03-03 16:03 出处:网络
As for the title. I don\'t want to add an annotation(@Json(format=\"yyyy-MM-dd HH:mm:ss\") on every getXXXDate(),can anybody gi开发者_开发百科ve a solution?You can use struts 2 json plugins in object

As for the title. I don't want to add an annotation(@Json(format="yyyy-MM-dd HH:mm:ss") on every getXXXDate(),can anybody gi开发者_开发百科ve a solution?


You can use struts 2 json plugins in object class, for example:

        private Date createdDate;

        @JSON(format="MM/dd/yyyy") 
  // or @JSON(format="date.format") from bundle resource properties files
        public Date getCreatedDate() {
            return createdDate;
        }

        public void setCreatedDate(Date createdDate) {
            this.createdDate = createdDate;
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消