I have this annotation
@Target(ElementType.METHOD)
@Retention(value = RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
@Documented
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Europe/Brussels")
public @interface MyDateFormat {
}
and this method:
@MyDateFormat
public LocalDate getCreationDate() {
return Optional.ofNullable(task)
.map(Task::getCreateTime)
.map(date -> date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate())
.orElse(null);
}
but I got it in long format
I have checked exactly the same code. It works as expected.