Package org.elasticsearch.common.time
Class JavaDateMathParser
java.lang.Object
org.elasticsearch.common.time.JavaDateMathParser
- All Implemented Interfaces:
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].-
Method Summary
Modifier and TypeMethodDescriptionparse(String text, LongSupplier now, boolean roundUpProperty, ZoneId timeZone) Parse text, that potentially contains date math into the milliseconds since the epoch Examples are2014-11-18||-2ysubtracts two years from the input datenow/mrounds 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 secondMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.time.DateMathParser
parse, parse
-
Method Details
-
parse
Description copied from interface:DateMathParserParse text, that potentially contains date math into the milliseconds since the epoch Examples are2014-11-18||-2ysubtracts two years from the input datenow/mrounds 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:
parsein interfaceDateMathParser- Parameters:
text- the inputnow- a supplier to retrieve the current date in milliseconds, if needed for additionsroundUpProperty- should the result be rounded up with the granularity of the rounding (e.g.now/M)timeZone- an optional timezone that should be applied before returning the milliseconds since the epoch- Returns:
- the parsed date as an Instant since the epoch
-