我正在使用GsonBuilder
将字符串解析为SleepSessionMessage
类类型,但是得到了unparseable date exception on "changeTimeStamp" field
。我已经检查了我的JSON字符串,并且很好,还检查了Epoch
时间,不确定是什么错误:
public class SleepSessionMessage extends SleepSession implements SiqMessage {
private static transient Gson gson = new GsonBuilder().create();
public static SleepSessionMessage fromJson(String jsonString) {
SleepSessionMessage sleepSessionMessage = null;
try {
sleepSessionMessage = new .fromJson(jsonString, SleepSessionMessage.class);
} catch (Exception e) {
logger.error("Failed in fromJson@SleepSessionMessage", e);
}
return sleepSessionMessage;
}
以下是引发的异常:
java.text.ParseException: Unparseable date: "1538773089927"
这是我正在使用的JSON字符串:
{
"type": null,
"changeTimeStamp": 1538773089927,
"bamUserId": 1538773089927,
"calcVersion": null,
"endDate": 1538773089927,
"duration": null,
"restfulTime": null,
"sleepQuotient": null,
"minHeartRate": null,
"maxHeartRate": null,
"avgHeartRate": null,
"minRespirationRate": null,
"maxRespirationRate": null,
"avgRespirationRate": null,
"minMotion": null,
"maxMotion": null,
"avgMotion": null,
"percentMotion": null,
"sleepStartDate": null,
"sleepEndDate": null,
"sleepDuration": null,
"fallAsleepPeriod": null,
"wakeUpPeriod": null,
"sessionStatus": null,
"motionNoiseThreshold": null,
"noMotionPressure": null,
"minNormalizedMotion": null,
"maxNormalizedMotion": null,
"avgNormalizedMotion": null,
"sleepDebt": null,
"inAndOut": null,
"percentSnoring": null,
"percentGoodHR": null,
"fiveMinWithNoHRCount": null,
"fifteenMinWithNoHRCount": null,
"sleepNumber": null,
"timeToFallSleep": null,
"startDate": 1538773089927,
"segStartDate": null,
"fallAsleepDate": null,
"hiddenChangeDate": null,
"ossExists": null,
"ossMinDuration": null,
"ossMaxDuration": null,
"ossAvgDuration": null,
"ossMinRestfulTime": null,
"ossMaxRestfulTime": null,
"ossAvgRestfulTime": null,
"ossMinSleepQuotient": null,
"ossMaxSleepQuotient": null,
"ossAvgSleepQuotient": null,
"ossMinHeartRate": null,
"ossMaxHeartRate": null,
"ossAvgHeartRate": null,
"ossMinRespirationRate": null,
"ossMaxRespirationRate": null,
"ossAvgRespirationRate": null,
"ossMinMotion": null,
"ossMaxMotion": null,
"ossAvgMotion": null,
"ossMinPercentMotion": null,
"ossMaxPercentMotion": null,
"ossAvgPercentMotion": null,
"ossMinSleepDuration": null,
"ossMaxSleepDuration": null,
"ossAvgSleepDuration": null,
"ossMinFallAsleepPeriod": null,
"ossMaxFallAsleepPeriod": null,
"ossAvgFallAsleepPeriod": null,
"ossMinWakeupPeriod": null,
"ossMaxWakeupPeriod": null,
"ossAvgWakeupPeriod": null,
"ossMinNormalizedMotion": null,
"ossMaxNormalizedMotion": null,
"ossAvgNormalizedMotion": null,
"ossSleepDebtLastWeek": null,
"ossSleepDebtLastMonth": null,
"ossMinSleepDebt": null,
"ossMaxSleepDebt": null,
"ossAvgSleepDebt": null,
"ossAvgStartTime": null,
"ossAvgEndTime": null,
"ossMinInAndOut": null,
"ossMaxInAndOut": null,
"ossAvgInAndOut": null,
"ossMinPercentSnoring": null,
"ossMaxPercentSnoring": null,
"ossAvgPercentSnoring": null,
"isSleepSegment": null,
"sleepSegments": null,
"messageType": "START_MESSAGE",
"sessionUUID": null,
"topic": "topic.rollup.sleepsession",
"sentTime": 0,
"entriesCount": 0,
"key": null,
"sleepSession": true,
"hidden": null
}