Module spring.data.mongodb
Class DateOperators.DateOperatorFactory
java.lang.Object
org.springframework.data.mongodb.core.aggregation.DateOperators.DateOperatorFactory
- Enclosing class:
- DateOperators
- Author:
- Christoph Strobl, Matt Morrissette
-
Constructor Summary
ConstructorsConstructorDescriptionDateOperatorFactory(Object value) Creates newDateOperators.DateOperatorFactoryfor givenvaluethat resolves to a Date.DateOperatorFactory(String fieldReference) Creates newDateOperators.DateOperatorFactoryfor given fieldReference.DateOperatorFactory(AggregationExpression expression) Creates newDateOperators.DateOperatorFactoryfor givenAggregationExpression. -
Method Summary
Modifier and TypeMethodDescriptionCreates newAggregationExpressionthat adds the given value (in units).add(Object value, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat adds the given value (in units).addValueOf(String fieldReference, String unit) Creates newAggregationExpressionthat adds the value stored at the given field (in units).addValueOf(String fieldReference, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat adds the value stored at the given field (in units).addValueOf(AggregationExpression expression, String unit) Creates newAggregationExpressionthat adds the value of the givenexpression(in units).addValueOf(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat adds the value of the givenexpression(in units).Creates newAggregationExpressionthat returns the day of the month for a date as a number between 1 and 31.Creates newAggregationExpressionthat returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).Creates newAggregationExpressionthat returns the day of the year for a date as a number between 1 and 366.Creates newAggregationExpressionthat calculates the difference (in units) to the date given value.diff(Object value, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat calculates the difference (in units) to the date given value.diffValueOf(String fieldReference, String unit) Creates newAggregationExpressionthat calculates the difference (in units) to the date stored at the given field.diffValueOf(String fieldReference, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat calculates the difference (in units) to the date stored at the given field.diffValueOf(AggregationExpression expression, String unit) Creates newAggregationExpressionthat calculates the difference (in units) to the date computed by the givenexpression.diffValueOf(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat calculates the difference (in units) to the date computed by the givenexpression.Creates newAggregationExpressionthat converts a date/time string to a date object.
NOTE: Requires MongoDB 3.6 or later.hour()Creates newAggregationExpressionthat returns the hour portion of a date as a number between 0 and 23.Creates newAggregationExpressionthat returns the weekday number in ISO 8601-2018 format, ranging from 1 (for Monday) to 7 (for Sunday).isoWeek()Creates newAggregationExpressionthat returns the week number in ISO 8601-2018 format, ranging from 1 to 53.Creates newAggregationExpressionthat returns the year number in ISO 8601-2018 format.Creates newAggregationExpressionthat returns the millisecond portion of a date as an integer between 0 and 999.minute()Creates newAggregationExpressionthat returns the minute portion of a date as a number between 0 and 59.month()Creates newAggregationExpressionthat returns the month of a date as a number between 1 and 12.second()Creates newAggregationExpressionthat returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds.Creates newAggregationExpressionthat subtracts the given value (in units).subtract(Object value, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat subtracts the given value (in units).subtractValueOf(String fieldReference, String unit) Creates newAggregationExpressionthat subtracts the value stored at the given field (in units).subtractValueOf(String fieldReference, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat subtracts the value stored at the given field (in units).subtractValueOf(AggregationExpression expression, String unit) Creates newAggregationExpressionthat subtracts the value of the givenexpression(in units).subtractValueOf(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat subtracts the value of the givenexpression(in units).toParts()Creates newAggregationExpressionthat returns a document containing the constituent parts of the date as individual properties.
NOTE: Requires MongoDB 3.6 or later.Creates newAggregationExpressionthat converts a date object to a string according to a user-specified format.Creates newAggregationExpressionthat converts a date object to a string according to the server default format.Creates newAggregationExpressionthat truncates a date to the given unit.Creates newAggregationExpressionthat truncates a date to the given unit.Creates newAggregationExpressionthat returns the incrementing ordinal from a timestamp.tsSecond()Creates newAggregationExpressionthat returns the seconds from a timestamp.week()Creates newAggregationExpressionthat returns the week of the year for a date as a number between 0 and 53.withTimezone(DateOperators.Timezone timezone) Create a newDateOperators.DateOperatorFactorybound to a givenDateOperators.Timezone.
NOTE: Requires Mongo 3.6 or later.year()Creates newAggregationExpressionthat returns the year portion of a date.
-
Constructor Details
-
DateOperatorFactory
Creates newDateOperators.DateOperatorFactoryfor given fieldReference.- Parameters:
fieldReference- must not be null.
-
DateOperatorFactory
Creates newDateOperators.DateOperatorFactoryfor givenAggregationExpression.- Parameters:
expression- must not be null.
-
DateOperatorFactory
- Parameters:
value- must not be null.- Since:
- 2.1
-
-
Method Details
-
withTimezone
Create a newDateOperators.DateOperatorFactorybound to a givenDateOperators.Timezone.
NOTE: Requires Mongo 3.6 or later.- Parameters:
timezone- must not be null. UseDateOperators.Timezone.none()instead.- Returns:
- new instance of
DateOperators.DateOperatorFactory. - Throws:
IllegalArgumentException- if given timezone is null.- Since:
- 2.1
-
addValueOf
Creates newAggregationExpressionthat adds the value of the givenexpression(in units).- Parameters:
expression- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
addValueOf
public DateOperators.DateAdd addValueOf(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat adds the value of the givenexpression(in units).- Parameters:
expression- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
addValueOf
Creates newAggregationExpressionthat adds the value stored at the given field (in units).- Parameters:
fieldReference- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
addValueOf
Creates newAggregationExpressionthat adds the value stored at the given field (in units).- Parameters:
fieldReference- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
add
Creates newAggregationExpressionthat adds the given value (in units).- Parameters:
value- must not be null.unit- the unit of measure. Must not be null.- Returns:
- Since:
- 3.3 new instance of
DateOperators.DateAdd.
-
add
Creates newAggregationExpressionthat adds the given value (in units).- Parameters:
value- must not be null.unit- the unit of measure. Must not be null.- Returns:
- Since:
- 3.3 new instance of
DateOperators.DateAdd.
-
subtractValueOf
Creates newAggregationExpressionthat subtracts the value of the givenexpression(in units).- Parameters:
expression- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateSubtract. - Since:
- 4.0
-
subtractValueOf
public DateOperators.DateSubtract subtractValueOf(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat subtracts the value of the givenexpression(in units).- Parameters:
expression- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateSubtract. - Since:
- 4.0
-
subtractValueOf
Creates newAggregationExpressionthat subtracts the value stored at the given field (in units).- Parameters:
fieldReference- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateSubtract. - Since:
- 4.0
-
subtractValueOf
public DateOperators.DateSubtract subtractValueOf(String fieldReference, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat subtracts the value stored at the given field (in units).- Parameters:
fieldReference- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateSubtract. - Since:
- 4.0
-
subtract
Creates newAggregationExpressionthat subtracts the given value (in units).- Parameters:
value- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateSubtract. - Since:
- 4.0
-
subtract
Creates newAggregationExpressionthat subtracts the given value (in units).- Parameters:
value- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateSubtract. - Since:
- 4.0
-
truncate
Creates newAggregationExpressionthat truncates a date to the given unit.- Parameters:
unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateTrunc. - Since:
- 4.0
-
truncate
Creates newAggregationExpressionthat truncates a date to the given unit.- Parameters:
unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateTrunc. - Since:
- 4.0
-
dayOfYear
Creates newAggregationExpressionthat returns the day of the year for a date as a number between 1 and 366.- Returns:
- new instance of
DateOperators.DayOfYear.
-
dayOfMonth
Creates newAggregationExpressionthat returns the day of the month for a date as a number between 1 and 31.- Returns:
- new instance of
DateOperators.DayOfMonth.
-
dayOfWeek
Creates newAggregationExpressionthat returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).- Returns:
- new instance of
DateOperators.DayOfWeek.
-
diffValueOf
Creates newAggregationExpressionthat calculates the difference (in units) to the date computed by the givenexpression.- Parameters:
expression- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
diffValueOf
public DateOperators.DateDiff diffValueOf(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpressionthat calculates the difference (in units) to the date computed by the givenexpression.- Parameters:
expression- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
diffValueOf
Creates newAggregationExpressionthat calculates the difference (in units) to the date stored at the given field.- Parameters:
fieldReference- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
diffValueOf
Creates newAggregationExpressionthat calculates the difference (in units) to the date stored at the given field.- Parameters:
fieldReference- must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
diff
Creates newAggregationExpressionthat calculates the difference (in units) to the date given value.- Parameters:
value- anything the resolves to a valid date. Must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
diff
Creates newAggregationExpressionthat calculates the difference (in units) to the date given value.- Parameters:
value- anything the resolves to a valid date. Must not be null.unit- the unit of measure. Must not be null.- Returns:
- new instance of
DateOperators.DateAdd. @since 3.3
-
year
Creates newAggregationExpressionthat returns the year portion of a date.- Returns:
- new instance of
DateOperators.Year.
-
month
Creates newAggregationExpressionthat returns the month of a date as a number between 1 and 12.- Returns:
- new instance of
DateOperators.Month.
-
week
Creates newAggregationExpressionthat returns the week of the year for a date as a number between 0 and 53.- Returns:
- new instance of
DateOperators.Week.
-
hour
Creates newAggregationExpressionthat returns the hour portion of a date as a number between 0 and 23.- Returns:
- new instance of
DateOperators.Hour.
-
minute
Creates newAggregationExpressionthat returns the minute portion of a date as a number between 0 and 59.- Returns:
- new instance of
DateOperators.Minute.
-
second
Creates newAggregationExpressionthat returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds.- Returns:
- new instance of
DateOperators.Second.
-
millisecond
Creates newAggregationExpressionthat returns the millisecond portion of a date as an integer between 0 and 999.- Returns:
- new instance of
DateOperators.Millisecond.
-
toString
Creates newAggregationExpressionthat converts a date object to a string according to a user-specified format.- Parameters:
format- must not be null.- Returns:
- new instance of
DateOperators.DateToString.
-
toStringWithDefaultFormat
Creates newAggregationExpressionthat converts a date object to a string according to the server default format.- Returns:
- new instance of
DateOperators.DateToString. - Since:
- 2.1
-
isoDayOfWeek
Creates newAggregationExpressionthat returns the weekday number in ISO 8601-2018 format, ranging from 1 (for Monday) to 7 (for Sunday).- Returns:
- new instance of
DateOperators.IsoDayOfWeek.
-
isoWeek
Creates newAggregationExpressionthat returns the week number in ISO 8601-2018 format, ranging from 1 to 53.- Returns:
- new instance of
DateOperators.IsoWeek.
-
isoWeekYear
Creates newAggregationExpressionthat returns the year number in ISO 8601-2018 format.- Returns:
- new instance of
DateOperators.IsoWeekYear.
-
toParts
Creates newAggregationExpressionthat returns a document containing the constituent parts of the date as individual properties.
NOTE: Requires MongoDB 3.6 or later.- Returns:
- new instance of
DateOperators.DateToParts. - Since:
- 2.1
-
fromString
Creates newAggregationExpressionthat converts a date/time string to a date object.
NOTE: Requires MongoDB 3.6 or later.- Returns:
- new instance of
DateOperators.DateFromString. - Since:
- 2.1
-
tsIncrement
Creates newAggregationExpressionthat returns the incrementing ordinal from a timestamp.- Returns:
- new instance of
DateOperators.TsIncrement. - Since:
- 4.0
-
tsSecond
Creates newAggregationExpressionthat returns the seconds from a timestamp.- Returns:
- new instance of
DateOperators.TsIncrement. - Since:
- 4.0
-