Auditing should support Java 8 Date & Time types [DATACMNS-411]
See original GitHub issueNick Williams opened DATACMNS-411 and commented
This may or may not be in the right project. I think it is, but it may need to be moved to Spring Data Commons.
Currently, fields annotated @CreatedDate
and @LastModifiedDate
can be Joda Time’s DateTime
or (I think) java.util.Date
, java.util.Calendar
, or java.sql.Timestamp
. If it doesn’t support these last three types, it should.
Auditing should also support the Java 8 Date & Time API. Fields modified with one of these two annotations should be able to be java.time.Instant
, java.time.LocalDateTime
, java.time.OffsetDateTime
, and java.time.ZonedDateTime
Affects: 1.7 M1 (Codd), 1.6.3 (Babbage SR2)
Issue Links:
-
SPR-11259 Add Converter implementations that convert legacy Date instances into JDK 8 date/time types (“depends on”)
-
DATAJPA-592 Auditing annotations not working when applied to methods
-
DATACMNS-307 Remove JodaTime dependency
Referenced from: commits https://github.com/spring-projects/spring-data-commons/commit/51b128fac1c17c8327d6fdd8c7ef87b039ac6c60
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:30 (4 by maintainers)
I can’t believe that this is still not working in 2021… For everyone tired of all this, just create this configuration class:
(Kotlin)
Using
LocalDateTime
as the basis certainly was a mistake an we should probable fix that.That said, discussing this on an issue that was closed 8 years ago isn’t helpful either.
For the record: The issue was closed because we do support Java 8
java.time
classes to the extend that we actually want to: Anything with time zone is really out of place in my and not only in my opinion, especially since support for those in JPA and JDBC is … sketchy.In order to get this ticket here it’s well earned rest:
LocalDate
toInstant
please create a ticket for it. For that one a PR even without a ticket has also a good chance of acceptance.OffsetDateTime
you are free to create a fresh ticket as well. Just be aware that you’ll probably have to do some convincing.