使用 fastjson 设置Date类型的数据时,会将其转换为时间戳(Long型),如果想要获取该数据,只需要把时间戳转换为日期即可。
JSONObject jsonObject = new JSONObject();
jsonObject.put("date", new Date());
String s = jsonObject.toJSONString();
JSONObject jsonObject1 = JSONObject.parseObject(s);
Long date = (Long) jsonObject1.get("date");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
String format = simpleDateFormat.format(new Date(date));
System.out.println(format);