I have the following date field in my DTO class:
@JsonFormat(pattern="dd.MM.yyyy")
private LocalDateTime date;
I define the date format in my application.yml as shown below:
spring:
jackson:
date-format: "dd.MM.yyyy"
I am trying to use this format in my DTO field directly like below:
@JsonFormat(pattern="${spring.jackson.date-format}")
private LocalDateTime date;
Is it possible? Or do ı have to add a @Value
field like below? I tried but cannot use this dateFormat
in my date field.
@Value("${spring.jackson.date-format}")
private String dateFormat;