Package org.elasticsearch.common.joda
Class JodaDateMathParser
- java.lang.Object
-
- org.elasticsearch.common.joda.JodaDateMathParser
-
- All Implemented Interfaces:
DateMathParser
public class JodaDateMathParser extends java.lang.Object implements DateMathParser
A parser for date/time formatted text with optional date math. The format of the datetime is configurable, and unix timestamps can also be used. Datemath is appended to a datetime with the following syntax:||[+-/](\d+)?[yMwdhHms]
.
-
-
Constructor Summary
Constructors Constructor Description JodaDateMathParser(FormatDateTimeFormatter dateTimeFormatter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
parse(java.lang.String text, java.util.function.LongSupplier now, boolean roundUp, java.time.ZoneId tz)
Parse text, that potentially contains date math into the milliseconds since the epoch Examples are2014-11-18||-2y
subtracts two years from the input datenow/m
rounds the current time to minute granularity Supported rounding units are y year M month w week (beginning on a monday) d day h/H hour m minute s second-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.time.DateMathParser
parse, parse
-
-
-
-
Constructor Detail
-
JodaDateMathParser
public JodaDateMathParser(FormatDateTimeFormatter dateTimeFormatter)
-
-
Method Detail
-
parse
public long parse(java.lang.String text, java.util.function.LongSupplier now, boolean roundUp, java.time.ZoneId tz)
Description copied from interface:DateMathParser
Parse text, that potentially contains date math into the milliseconds since the epoch Examples are2014-11-18||-2y
subtracts two years from the input datenow/m
rounds the current time to minute granularity Supported rounding units are y year M month w week (beginning on a monday) d day h/H hour m minute s second- Specified by:
parse
in interfaceDateMathParser
- Parameters:
text
- the inputnow
- a supplier to retrieve the current date in milliseconds, if needed for additionsroundUp
- should the result be rounded uptz
- an optional timezone that should be applied before returning the milliseconds since the epoch- Returns:
- the parsed date in milliseconds since the epoch
-
-