【发布时间】:2019-05-07 19:42:06
【问题描述】:
@Data
public class SampleDate {
private Date revisiondate;
}
@RequestMapping("/date")
public ResponseEntity<List<SampleDate>> getDateSample()
{
List<SampleDate> listDate = new ArrayList<>();
SampleDate sampDate = new SampleDate();
sampDate.setRevisiondate(new Date());
listDate.add(sampDate);
return new ResponseEntity<>(listDate,HttpStatus.OK);
}
输出:[{"revisiondate":"2018-12-06T06:06:18.795+0000"}]
预期输出:[{"revisiondate":1544077577462}]
我使用的是 Springboot 2.0.3.RELEASE 版本。在 Springboot 1.3.2.RELEASE 版本中,我能够实现这一点。有没有人在升级 Springboot 时遇到过这种情况。
【问题讨论】:
-
是什么让你想要那个输出?您已经拥有的那个更具可读性。输出采用国际标准 ISO 8601 格式,因此应该被广泛接受。
-
实际上我们正在升级生产中的 SOA 服务(Springboot 1.3.2.RELEASE)。所以我们需要得到与生产代码完全相同的输出。
标签: java date spring-boot datetime epoch