在响应正文中更改日期格式 [英] Change date format in responsebody
本文介绍了在响应正文中更改日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有requestmapping的spring应用程序,该应用程序返回json中的Accounts列表。
Account类具有Date属性。此属性在json输出中作为unix时间戳返回。
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.
是否可以将dateformat更改为预定义格式,而不是将其作为unix时间戳返回?
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;
}
推荐答案
从JSON中获取时间戳提要并转换为您的JSP文件。
您可以使用javascript做到这一点:将Unix时间戳转换为使用JavaScript的时间
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
这篇关于在响应正文中更改日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文