Class JodaDateMathParser

All Implemented Interfaces:

public class JodaDateMathParser extends 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 Details

    • JodaDateMathParser

      public JodaDateMathParser(JodaDateFormatter dateTimeFormatter)
  • Method Details

    • parse

      public Instant parse(String text, LongSupplier now, boolean roundUp, ZoneId tz)
      Description copied from interface: DateMathParser
      Parse text, that potentially contains date math into the milliseconds since the epoch Examples are 2014-11-18||-2y subtracts two years from the input date now/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 interface DateMathParser
      text - the input
      now - a supplier to retrieve the current date in milliseconds, if needed for additions
      roundUp - 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
      the parsed date as an Instant since the epoch