Skip to content

Formatting LocalDate and LocalDateTime #1494

Answered by beikov
rclarke1 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there. You can still use @JsonFormat if you like. Otherwise, you can also use the DateTimeFormatter API like this in your entity views:

@EntityView(MyEntity.class)
public interface MyEntityView {

    @Mapping("date")
    @JsonIgnore
    LocalDate getDateAsObject();

    default String getDate() {
        return DateTimeFormatter.ISO_LOCAL_DATE.format(getDateAsObject());
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rclarke1
Comment options

Answer selected by rclarke1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants