1

unsupportedtemporaltypeexception with @JsonFormat on POJO with the property of type java.time.Instant

Error java.time.temporal.unsupportedtemporaltypeexception unsupported field yearofera

I do not want to write a manual code for conversion. Please suggest some other way

class MyClass{
    @JsonFormat(shape= Shape.String, pattern="yyyy-dd-mm HH:mm:ss")
    private Instant createTime;
}
  • 1
    Use LocalDateTime in place of Instant – kumesana Aug 22 '19 at 16:07
  • @dai i do not want to do it manually, that is the last option. Instead in that case i'll write my own custom annotation to do so – Mayank Jalotra Aug 23 '19 at 17:19
  • @kumesana As a standard in our entities we are using Instant and would not like to change it – Mayank Jalotra Aug 23 '19 at 17:21
  • Please, I'm begging you, stick to the standard ISO-8601 format. It's unambiguous, and usable by any client. The standard exists for a reason. Don't use your own, proprietary, ambiguous format (which BTW doesn't even contain the month). – JB Nizet Aug 23 '19 at 17:24

0 Answers0