For simplicity let's assume we're talking about a classic web application that has backend written in Java, has a SQL database and communicates through REST.
My question is: What is the best java.time
class to represent some point in time (e.g. time when a comment was posted) in a data structure-like class (DTO, JPA Entity, Model)? I've already seen it all: LocalDateTime
, ZonedDateTime
, Date
, Instant
. Especially LocalDateTime
as a field in JPA Entity just doesn't feel right. What should be used? ZonedDateTime? OffsetDateTime? Instant? "Good" old java.util.Date and convert it into some java.time
object only when some date calculations are needed?