JSON 时间date()对象转码错误问题

问题:Can't transform property 'createDate' from java.lang.String into java.util.D

2020-08-25 11:08:00,323 WARN  [net.sf.json.JSONObject] - Can't transform property 'createDate' from java.lang.String into java.util.Date. Will register a default BeanMorpher
2020-08-25 11:08:00,327 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.time' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.minutes' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.seconds' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.hours' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.month' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.year' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.date' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.time' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.minutes' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.seconds' does not exist. SKIPPED.
2020-08-25 11:08:00,328 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.hours' does not exist. SKIPPED.
2020-08-25 11:08:00,329 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.month' does not exist. SKIPPED.
2020-08-25 11:08:00,329 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.year' does not exist. SKIPPED.
2020-08-25 11:08:00,329 WARN  [net.sf.ezmorph.bean.BeanMorpher] - Property 'java.lang.String.date' does not exist. SKIPPED.

此问题是因为json字符串内的时间格式不匹配造成的,解决问题方案:

JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(new String[] {"yyyy-MM-dd HH:mm:ss"}) );

自定义时间转码格式即可

你可能感兴趣的:(错误汇总,fastJson)