There is a closed ticket suggesting that Ebean 4.4.1 and onwards supports Java 8's time classes, such as OffsetDateTime. However, I can't find any Ebean documentation showing the use these classes.
For a class such as AppUser shown below, is it fully supported to use OffsetDateTime instead of java.sql.Timestamp?
@Entity
public class AppUser extends Model {
@Id
private Long id;
private String username;
private OffsetDateTime lastSeen;
// Constructor, getters and setters
}
There is no docs for these new types, but the code is pretty simple and straightforward:
https://github.com/ebean-orm/avaje-ebeanorm/blob/master/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeOffsetDateTime.java
As you can see at the code, OffsetDateTime is mapped to a java.sql.Timestamp. Here is a (likely) complete table of how Ebean maps java.time types to java.sql.Types:
| Java 8 java.time.* | java.sql.Types |
|:---------------------------------|:---------------|
| DayOfWeek | INTEGER |
| Duration | BIGINT |
| Duration (with nanos precision) | DECIMAL |
| Instant | TIMESTAMP |
| LocalDate | DATE |
| LocalDateTime | TIMESTAMP |
| LocalTime | TIME |
| LocalTime (with nanos precision) | BIGINT |
| Month | INTEGER |
| MonthDay | DATE |
| OffsetDateTime | TIMESTAMP |
| OffsetTime | VARCHAR |
| Year | INTEGER |
| YearMonth | DATE |
| ZoneId | VARCHAR |
| ZoneOffset | VARCHAR |
| ZonedDateTime | TIMESTAMP |
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With