diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/HibernateCriteriaBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/HibernateCriteriaBuilder.java index 8f9aae024f..e8272a331c 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/HibernateCriteriaBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/HibernateCriteriaBuilder.java @@ -998,6 +998,18 @@ public interface HibernateCriteriaBuilder extends CriteriaBuilder { @Incubating JpaFunction second(Expression datetime); + /** + * Truncates a date, time or datetime expression to the given {@link TemporalUnit}. + * Supported units are: {@code YEAR}, {@code MONTH}, {@code DAY}, {@code HOUR}, {@code MINUTE}, {@code SECOND}. + *

+ * Truncating translates to obtaining a value of the same type in which all temporal units smaller than {@code field} have been pruned. + * For hours, minutes and second this means setting them to {@code 00}. For months and days, this means setting them to {@code 01}. + * + * @param datetime the date, time or datetime expression to be truncated + * @param temporalUnit the temporal unit for truncation + * + * @return the truncated value + */ @Incubating JpaFunction truncate(Expression datetime, TemporalUnit temporalUnit);