Class DateTruncExpression
- java.lang.Object
-
- dev.morphia.aggregation.expressions.impls.Expression
-
- dev.morphia.aggregation.expressions.impls.DateTruncExpression
-
public class DateTruncExpression extends Expression
Truncates a date.- Since:
- 2.3
- Since server release
- 5.0
-
-
Constructor Summary
Constructors Constructor Description DateTruncExpression(Expression date, TimeUnit unit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DateTruncExpressionbinSize(long binSize)The numeric time value, specified as an expression that must resolve to a positive non-zero number.voidencode(Datastore datastore, BsonWriter writer, EncoderContext encoderContext)DateTruncExpressionstartOfWeek(DayOfWeek startOfWeek)The start of the week.DateTruncExpressiontimezone(Expression timezone)The timezone to carry out the operation.-
Methods inherited from class dev.morphia.aggregation.expressions.impls.Expression
getOperation, getValue, toString
-
-
-
-
Constructor Detail
-
DateTruncExpression
public DateTruncExpression(Expression date, TimeUnit unit)
-
-
Method Detail
-
binSize
public DateTruncExpression binSize(long binSize)
The numeric time value, specified as an expression that must resolve to a positive non-zero number. Defaults to 1.Together, binSize and unit specify the time period used in the $dateTrunc calculation.
- Parameters:
binSize- the size to use- Returns:
- this
- Since:
- 2.3
-
encode
public void encode(Datastore datastore, BsonWriter writer, EncoderContext encoderContext)
- Overrides:
encodein classExpression- Parameters:
datastore- the datastorewriter- the writerencoderContext- the context
-
startOfWeek
public DateTruncExpression startOfWeek(DayOfWeek startOfWeek)
The start of the week. Used when unit is week. Defaults to Sunday.- Parameters:
startOfWeek- the start of the week- Returns:
- this
-
timezone
public DateTruncExpression timezone(Expression timezone)
The timezone to carry out the operation.must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. - Parameters:
timezone- the timezone expression- Returns:
- this
- Since:
- 2.3
-
-