Change date format in responsebody

北城以北 提交于 2019-12-08 01:54:24

问题


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;
        }

回答1:


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



来源:https://stackoverflow.com/questions/14736443/change-date-format-in-responsebody

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!