Tips on solving Error “Java 8 date/time type `java.time.Instant` not supported by default”

Java is a well-known language for the versatility it offers to programmers. It is a programing language that created a stir in the programming world when it is launched. There are many programs out there that can’t be performed without using Java. As it is a popular language that is frequently used for various programs, you are more likely to get errors, which is really common. You may also encounter the Error “Java 8 date/time type `java.time.Instant` not supported by default”.

The error is common as well, and there is no need to get panicked. You must have looked for the problem, but you are at the right place to get efficient and quick solutions to get rid of the error warning. Let’s have a look at how you encounter the error

How do you encounter the error?

You get the error warning when you are using Date-Time APIs in Java.  You may not understand the Java library, java.time.Instant. You must have issues understanding the instant library’s implementation.  When you are working on a spring-boot program for creating a RESTful service along with the CRUD operation, that too on MongoDB. You may not get any error warning until you use instant createdOn and updatedOn in DTO.

Have a look at the code where you encounter the error

  public ResponseEntity<ResponseDto> create(@RequestBody CLMDto CLMDto) {

    CLMDto createdCLMDto =

    return ResponseEntity.status(HttpStatus.CREATED)
            RESPONSE_HEADER_LOCATION, CLM_URL + "/" + createdCLMDto.getId())
        .body(ResponseDto.builder().value(createdCLMDto).build()); //--------------------->**Failing here**

The DTO response you get must be like this:

public class ResponseDto {

  private Integer count;
  private Object value;
  private Object error;
  private Object info;

Along with the following CLMDto:

public class AdminDataDto {
  private Instant createdOn;
  private Instant updatedOn;
  @JsonProperty(value = "updatedByName", access = JsonProperty.Access.READ_ONLY)
  private String updatedByName;

When using Lombok plugins, you may get the error

Type definition error: [simple type, class java.time.Instant]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Instant` not supported by default: add Module \”com.fasterxml.jackson.datatype:jackson-datatype-jsr310\” to enable handling

Now check out how to solve the issue

How to solve Error “Java 8 date/time type `java.time.Instant` not supported by default”

A few solutions are quite effective when it comes to solving the error warning.

Solution 1 – Dependency in pom.xml

This one is good enough to solve the error. You need to just include com.fasterxml.jackson.datatype in pom.xml. Follow this:


Solution 2 – The JavaTimeModule Registry

The next possible solution to fix the error “Java 8 date/time type `java.time.Instant` not supported by default” is to register JavaTimeModule. In the case of using com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in the classpath, you need to register only adding the dependency will not work along, you need to also declare a @Bean. You do this using the below code

public Module dateTimeModule(){ 
    return new JavaTimeModule();


I hope the solutions we have discussed to tackle the error “Java 8 date/time type `java.time.Instant` not supported by default” may help you. Solutions are effective yet simple to solve.

On that note, I wish you luck!

Reference Source:

Leave a Reply

Your email address will not be published. Required fields are marked *