Class DateHelper


  • public final class DateHelper
    extends Object
    Helper to add duration to a date with the same format as ES Date histogram interval
    Since:
    8.4
    • Method Detail

      • plusDuration

        public static ZonedDateTime plusDuration​(ZonedDateTime origin,
                                                 String duration)
        Returns a new ZonedDateTime plus the specified duration.
        Parameters:
        origin - the initial ZonedDateTime
        duration - can be expressed with a noun: hour, day, month, quarter, year or expression: 2d, 3h, 5w, 2M, 3y or a number of ms: 1234
        Returns:
        a new ZonedDateTime
        Throws:
        IllegalArgumentException - if the duration cannot be parsed