Spring returns 关于日期的大量信息
Spring returns lot of information about date
我是 spring 开发 spring 网络应用程序的新手。在应用程序中有一个 API 应该 return 我之前使用另一个 api 保存的日期。日期在 iOS 消耗。一切正常,但作为日期的一部分 returned 的数据量很大,我想知道是否可以将其关闭。这是数据示例:
"availability": {
"offset": {
"totalSeconds": -25200
"id": "-07:00"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
"zone": {
"id": "America/Los_Angeles"
"rules": {
"fixedOffset": false
"transitions": [127]
0: {
"offsetBefore": {
"totalSeconds": -28378
"id": "-07:52:58"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
"offsetAfter": {
"totalSeconds": -28800
"id": "-08:00"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
"duration": {
"seconds": -422
"negative": true
"zero": false
"units": [2]
0: "SECONDS"
1: "NANOS"
-
"nano": 0
}-
"gap": false
"overlap": true
"dateTimeAfter": {
"year": 1883
"month": "NOVEMBER"
"dayOfMonth": 18
"dayOfWeek": "SUNDAY"
"dayOfYear": 322
"monthValue": 11
"hour": 12
"minute": 0
"second": 0
"nano": 0
"chronology": {
"id": "ISO"
"calendarType": "iso8601"
}-
}-
"dateTimeBefore": {
"year": 1883
"month": "NOVEMBER"
"dayOfMonth": 18
"dayOfWeek": "SUNDAY"
"dayOfYear": 322
"monthValue": 11
"hour": 12
"minute": 7
"second": 2
"nano": 0
"chronology": {
"id": "ISO"
"calendarType": "iso8601"
}-
}-
"instant": {
"nano": 0
"epochSecond": -2717640000
}-
}-
1: {
"offsetBefore": {
"totalSeconds": -28800
"id": "-08:00"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
我不需要所有这些数据,因为我的查询需要很长时间才能到达 return。我是在做错什么还是遗漏了一些告诉 return 什么的标志。日期最初存储为 ZonedDateTime,还是我应该以其他格式存储日期?
您没有显示正在序列化的 POJO。所以我打赌你正在使用一些日期抽象,比如 Joda Time 或 Java8 的 LocalDateTime
。您可能希望将此 POJO 更改为仅包含简单的 Long
时间戳或仅包含 Date
,它应该被序列化为从 1970 年开始的毫秒数。
对于提到的转换,请查看这些 SO 答案:
Converting between java.time.LocalDateTime and java.util.Date
How to get milliseconds from LocalDateTime in Java 8
我是 spring 开发 spring 网络应用程序的新手。在应用程序中有一个 API 应该 return 我之前使用另一个 api 保存的日期。日期在 iOS 消耗。一切正常,但作为日期的一部分 returned 的数据量很大,我想知道是否可以将其关闭。这是数据示例:
"availability": {
"offset": {
"totalSeconds": -25200
"id": "-07:00"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
"zone": {
"id": "America/Los_Angeles"
"rules": {
"fixedOffset": false
"transitions": [127]
0: {
"offsetBefore": {
"totalSeconds": -28378
"id": "-07:52:58"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
"offsetAfter": {
"totalSeconds": -28800
"id": "-08:00"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
"duration": {
"seconds": -422
"negative": true
"zero": false
"units": [2]
0: "SECONDS"
1: "NANOS"
-
"nano": 0
}-
"gap": false
"overlap": true
"dateTimeAfter": {
"year": 1883
"month": "NOVEMBER"
"dayOfMonth": 18
"dayOfWeek": "SUNDAY"
"dayOfYear": 322
"monthValue": 11
"hour": 12
"minute": 0
"second": 0
"nano": 0
"chronology": {
"id": "ISO"
"calendarType": "iso8601"
}-
}-
"dateTimeBefore": {
"year": 1883
"month": "NOVEMBER"
"dayOfMonth": 18
"dayOfWeek": "SUNDAY"
"dayOfYear": 322
"monthValue": 11
"hour": 12
"minute": 7
"second": 2
"nano": 0
"chronology": {
"id": "ISO"
"calendarType": "iso8601"
}-
}-
"instant": {
"nano": 0
"epochSecond": -2717640000
}-
}-
1: {
"offsetBefore": {
"totalSeconds": -28800
"id": "-08:00"
"rules": {
"fixedOffset": true
"transitions": [0]
"transitionRules": [0]
}-
}-
我不需要所有这些数据,因为我的查询需要很长时间才能到达 return。我是在做错什么还是遗漏了一些告诉 return 什么的标志。日期最初存储为 ZonedDateTime,还是我应该以其他格式存储日期?
您没有显示正在序列化的 POJO。所以我打赌你正在使用一些日期抽象,比如 Joda Time 或 Java8 的 LocalDateTime
。您可能希望将此 POJO 更改为仅包含简单的 Long
时间戳或仅包含 Date
,它应该被序列化为从 1970 年开始的毫秒数。
对于提到的转换,请查看这些 SO 答案:
Converting between java.time.LocalDateTime and java.util.Date
How to get milliseconds from LocalDateTime in Java 8