2

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 give a solution?

vivia
  • 21
  • 2
  • I don’t think I understand the question. Are you looking for a global date formatter? Please clarify the question with additional context. – johnnieb May 11 '11 at 19:17
  • @johnnieb Yes, I am looking for a global date formatter. – vivia May 23 '11 at 09:37

1 Answers1

6

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;
        }
SonTL
  • 361
  • 4
  • 6