Package org.elasticsearch.common.time
Interface DateMathParser
- All Known Implementing Classes:
JavaDateMathParser
public interface DateMathParser
An abstraction over date math parsing.
Note: This can now be collapsed together with
JavaDateMathParser
since Joda is removed.-
Method Summary
Modifier and TypeMethodDescriptiondefault Instant
parse
(String text, LongSupplier now) Parse a date math expression without timezone info and rounding down.parse
(String text, LongSupplier now, boolean roundUpProperty, 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
-
Method Details
-
parse
Parse a date math expression without timezone info and rounding down. -
parse
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- 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
)tz
- an optional timezone that should be applied before returning the milliseconds since the epoch- Returns:
- the parsed date as an Instant since the epoch
-