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.DateOperatorFactory
for givenvalue
that resolves to a Date.DateOperatorFactory
(String fieldReference) Creates newDateOperators.DateOperatorFactory
for given fieldReference.DateOperatorFactory
(AggregationExpression expression) Creates newDateOperators.DateOperatorFactory
for givenAggregationExpression
. -
Method Summary
Modifier and TypeMethodDescriptionCreates newAggregationExpression
that adds the given value (in units).add
(Object value, DateOperators.TemporalUnit unit) Creates newAggregationExpression
that adds the given value (in units).addValueOf
(String fieldReference, String unit) Creates newAggregationExpression
that adds the value stored at the given field (in units).addValueOf
(String fieldReference, DateOperators.TemporalUnit unit) Creates newAggregationExpression
that adds the value stored at the given field (in units).addValueOf
(AggregationExpression expression, String unit) Creates newAggregationExpression
that adds the value of the givenexpression
(in units).addValueOf
(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpression
that adds the value of the givenexpression
(in units).Creates newAggregationExpression
that returns the day of the month for a date as a number between 1 and 31.Creates newAggregationExpression
that returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).Creates newAggregationExpression
that returns the day of the year for a date as a number between 1 and 366.Creates newAggregationExpression
that calculates the difference (in units) to the date given value.diff
(Object value, DateOperators.TemporalUnit unit) Creates newAggregationExpression
that calculates the difference (in units) to the date given value.diffValueOf
(String fieldReference, String unit) Creates newAggregationExpression
that calculates the difference (in units) to the date stored at the given field.diffValueOf
(String fieldReference, DateOperators.TemporalUnit unit) Creates newAggregationExpression
that calculates the difference (in units) to the date stored at the given field.diffValueOf
(AggregationExpression expression, String unit) Creates newAggregationExpression
that calculates the difference (in units) to the date computed by the givenexpression
.diffValueOf
(AggregationExpression expression, DateOperators.TemporalUnit unit) Creates newAggregationExpression
that calculates the difference (in units) to the date computed by the givenexpression
.Creates newAggregationExpression
that converts a date/time string to a date object.
NOTE: Requires MongoDB 3.6 or later.hour()
Creates newAggregationExpression
that returns the hour portion of a date as a number between 0 and 23.Creates newAggregationExpression
that returns the weekday number in ISO 8601-2018 format, ranging from 1 (for Monday) to 7 (for Sunday).isoWeek()
Creates newAggregationExpression
that returns the week number in ISO 8601-2018 format, ranging from 1 to 53.Creates newAggregationExpression
that returns the year number in ISO 8601-2018 format.Creates newAggregationExpression
that returns the millisecond portion of a date as an integer between 0 and 999.minute()
Creates newAggregationExpression
that returns the minute portion of a date as a number between 0 and 59.month()
Creates newAggregationExpression
that returns the month of a date as a number between 1 and 12.second()
Creates newAggregationExpression
that returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds.toParts()
Creates newAggregationExpression
that returns a document containing the constituent parts of the date as individual properties.
NOTE: Requires MongoDB 3.6 or later.Creates newAggregationExpression
that converts a date object to a string according to a user-specified format.Creates newAggregationExpression
that converts a date object to a string according to the server default format.week()
Creates newAggregationExpression
that returns the week of the year for a date as a number between 0 and 53.withTimezone
(DateOperators.Timezone timezone) Create a newDateOperators.DateOperatorFactory
bound to a givenDateOperators.Timezone
.
NOTE: Requires Mongo 3.6 or later.year()
Creates newAggregationExpression
that returns the year portion of a date.
-
Constructor Details
-
DateOperatorFactory
Creates newDateOperators.DateOperatorFactory
for given fieldReference.- Parameters:
fieldReference
- must not be null.
-
DateOperatorFactory
Creates newDateOperators.DateOperatorFactory
for givenAggregationExpression
.- Parameters:
expression
- must not be null.
-
DateOperatorFactory
- Parameters:
value
- must not be null.- Since:
- 2.1
-
-
Method Details
-
withTimezone
Create a newDateOperators.DateOperatorFactory
bound 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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
.
-
dayOfYear
Creates newAggregationExpression
that returns the day of the year for a date as a number between 1 and 366.- Returns:
- new instance of
DateOperators.DayOfYear
.
-
dayOfMonth
Creates newAggregationExpression
that returns the day of the month for a date as a number between 1 and 31.- Returns:
- new instance of
DateOperators.DayOfMonth
.
-
dayOfWeek
Creates newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that 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 newAggregationExpression
that returns the year portion of a date.- Returns:
- new instance of
DateOperators.Year
.
-
month
Creates newAggregationExpression
that returns the month of a date as a number between 1 and 12.- Returns:
- new instance of
DateOperators.Month
.
-
week
Creates newAggregationExpression
that returns the week of the year for a date as a number between 0 and 53.- Returns:
- new instance of
DateOperators.Week
.
-
hour
Creates newAggregationExpression
that returns the hour portion of a date as a number between 0 and 23.- Returns:
- new instance of
DateOperators.Hour
.
-
minute
Creates newAggregationExpression
that returns the minute portion of a date as a number between 0 and 59.- Returns:
- new instance of
DateOperators.Minute
.
-
second
Creates newAggregationExpression
that 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 newAggregationExpression
that returns the millisecond portion of a date as an integer between 0 and 999.- Returns:
- new instance of
DateOperators.Millisecond
.
-
toString
Creates newAggregationExpression
that 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 newAggregationExpression
that converts a date object to a string according to the server default format.- Returns:
- new instance of
DateOperators.DateToString
. - Since:
- 2.1
-
isoDayOfWeek
Creates newAggregationExpression
that 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 newAggregationExpression
that returns the week number in ISO 8601-2018 format, ranging from 1 to 53.- Returns:
- new instance of
DateOperators.IsoWeek
.
-
isoWeekYear
Creates newAggregationExpression
that returns the year number in ISO 8601-2018 format.- Returns:
- new instance of
DateOperators.IsoWeekYear
.
-
toParts
Creates newAggregationExpression
that 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 newAggregationExpression
that 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
-