2

I have a spring application with a requestmapping that returns a list of Accounts in json. The Account class has a Date property. This property is returned as a unix timestamp in the json output.

Is there a way to change the dateformat to a predefined format instead of returning it as a unix timestamp?

@RequestMapping(value = "/userAccounts.json", method = RequestMethod.GET)
        public @ResponseBody ArrayList<Account> userAccounts() {
            ArrayList<Account> accounts = accountService.getAllUserAccounts(user);
            return accounts;
        }
heldt
  • 4,166
  • 7
  • 39
  • 67
  • See: http://java.dzone.com/articles/how-serialize-javautildate – Tomasz Nurkiewicz Feb 06 '13 at 18:48
  • I'm looking for a more global solution like: http://stackoverflow.com/questions/9038005/spring-3-1-json-date-format I have tried that solution but with no effect. – heldt Feb 06 '13 at 19:09
  • http://stackoverflow.com/questions/6685043/java-ee-what-is-the-correct-layer-for-formatting-domain-model-objects-before-p/6687472#6687472 – Marcin Wasiluk Feb 11 '13 at 23:58

1 Answers1

0

Take the timestamp from your JSON feed and convert in your JSP file. You can do that using javascript: Convert a Unix timestamp to time in JavaScript

Community
  • 1
  • 1
drt
  • 713
  • 6
  • 9