Class StandardValueConverter
java.lang.Object
de.chojo.sadu.queries.converter.StandardValueConverter
The StandardValueConverter class provides a set of predefined ValueConverters for various types.
Each ValueConverter maps between a Java type and an intermediate SQL type.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ValueConverter<Instant, Long> Writes and readsInstantas unix epoch in millisecondsstatic final ValueConverter<Instant, Long> Writes and readsInstantas unix epoch in secondsstatic final ValueConverter<Instant, Timestamp> static final ValueConverter<LocalDate, Date> static final ValueConverter<LocalDateTime, Timestamp> Writes and readsLocalDateTimeasTimestampstatic final ValueConverter<LocalTime, Time> static final ValueConverter<OffsetDateTime, Timestamp> Writes and readsOffsetDateTimeasTimestamp.static final ValueConverter<OffsetTime, Time> Writes and readsOffsetTimeasTime.static final ValueConverter<UUID, byte[]> static final ValueConverter<UUID, String> static final ValueConverter<ZonedDateTime, Timestamp> Writes and readsZonedDateTimeasTimestamp. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Enum<T>>
@NotNull ValueConverter<T, String> static @NotNull ValueConverter<LocalDate, Date> static @NotNull ValueConverter<LocalDateTime, Timestamp> localDateTime(Calendar calendar) Writes and readsLocalDateTimeasTimestampstatic @NotNull ValueConverter<LocalTime, Time> static @NotNull ValueConverter<OffsetDateTime, Timestamp> offsetDateTime(Calendar calendar) Writes and readsZonedDateTimeasTimestamp.static @NotNull ValueConverter<OffsetTime, Time> offsetTime(Calendar calendar) Writes and readsOffsetTimeasTime.static @NotNull ValueConverter<ZonedDateTime, Timestamp> zonedDateTime(Calendar calendar) Writes and readsZonedDateTimeasTimestamp.
-
Field Details
-
INSTANT_MILLIS
Writes and readsInstantas unix epoch in milliseconds -
INSTANT_SECONDS
Writes and readsInstantas unix epoch in seconds -
INSTANT_TIMESTAMP
-
LOCAL_DATE_TIME
Writes and readsLocalDateTimeasTimestamp -
OFFSET_DATE_TIME
Writes and readsOffsetDateTimeasTimestamp. Will be stored in UTC. -
ZONED_DATE_TIME
Writes and readsZonedDateTimeasTimestamp. Will be stored in UTC. -
OFFSET_TIME
-
LOCAL_DATE
-
LOCAL_TIME
-
UUID_STRING
-
UUID_BYTES
-
-
Constructor Details
-
StandardValueConverter
public StandardValueConverter()
-
-
Method Details
-
forEnum
@Contract("_ -> new") @NotNull public static <T extends Enum<T>> @NotNull ValueConverter<T,String> forEnum(Class<T> clazz) - Type Parameters:
T- enum type- Parameters:
clazz- enum class- Returns:
- A new
ValueConverterinstance for that specific enum type
-
localDate
@Contract("_ -> new") @NotNull public static @NotNull ValueConverter<LocalDate, Date> localDate(Calendar calendar) - Parameters:
calendar- The calendar used to construct the date- Returns:
- A new
ValueConverterinstance using theCalendar
-
localTime
@Contract("_ -> new") @NotNull public static @NotNull ValueConverter<LocalTime, Time> localTime(Calendar calendar) - Parameters:
calendar- The calendar used to construct the timestamp- Returns:
- A new
ValueConverterinstance using theCalendar
-
offsetTime
@Contract("_ -> new") @NotNull public static @NotNull ValueConverter<OffsetTime, Time> offsetTime(Calendar calendar) - Parameters:
calendar- The calendar used to construct the time- Returns:
- A new
ValueConverterinstance using theCalendar
-
localDateTime
@Contract("_ -> new") @NotNull public static @NotNull ValueConverter<LocalDateTime, Timestamp> localDateTime(Calendar calendar) Writes and readsLocalDateTimeasTimestamp- Parameters:
calendar- The calendar used to construct the timestamp- Returns:
- A new
ValueConverterinstance using theCalendar
-
offsetDateTime
@Contract("_ -> new") @NotNull public static @NotNull ValueConverter<OffsetDateTime, Timestamp> offsetDateTime(Calendar calendar) Writes and readsZonedDateTimeasTimestamp. Will be stored in UTC.- Parameters:
calendar- The calendar used to construct the timestamp- Returns:
- A new
ValueConverterinstance using theCalendar
-
zonedDateTime
@Contract("_ -> new") @NotNull public static @NotNull ValueConverter<ZonedDateTime, Timestamp> zonedDateTime(Calendar calendar) Writes and readsZonedDateTimeasTimestamp. Will be stored in UTC.- Parameters:
calendar- The calendar used to construct the timestamp- Returns:
- A new
ValueConverterinstance using theCalendar
-