Answer the question
In order to leave comments, you need to log in
How to set time format in CreatedDate annotation in Spring?
I have this entity:
@Data
@EntityListeners(value = AuditingEntityListener.class)
public abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, updatable = false)
private Long id;
@Column(updatable = false)
@CreatedDate
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private LocalDateTime createdDate;
}
@Configuration
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
public class EntityListenerConfig {
@Bean
public AuditorAware<String> auditorProvider() {
return () -> Optional.ofNullable("system");
}
}
"createdDate": "2021-06-22T19:42:37.805621"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question