Rules
To UTC
Normalize a temporal value to its Instant representation in UTC.
Use toUtc() to convert any supported temporal type to a java.time.Instant and write it back to the field.
import static dev.ditsche.teki.rule.builder.Rules.*;
Teki schema = Teki.fromRules(
temporal("publishedAt").required().toUtc(),
temporal("updatedAt").toUtc()
);All timezone and offset information is applied before the conversion, so the resulting Instant represents the same point in time as the original value.
Input types
toUtc() accepts any temporal type that temporal() recognizes:
java.time.Instant— passed through unchangedjava.time.ZonedDateTime— offset applied, converted toInstantjava.time.OffsetDateTime— offset applied, converted toInstantjava.time.LocalDateTime— interpreted in the JVM default timezone, then convertedjava.time.LocalDate— start of day in the JVM default timezone, then convertedjava.util.Date— converted directlyjava.util.Calendar— converted directly
Available on
temporal(...)
Annotation equivalent
import dev.ditsche.teki.annotation.ToUtc;
public class ArticleRequest {
@ToUtc
private OffsetDateTime publishedAt;
}