Class Rounding

java.lang.Object
org.elasticsearch.common.Rounding
All Implemented Interfaces:
Writeable

public abstract class Rounding
extends java.lang.Object
implements Writeable
A strategy for rounding milliseconds since epoch.

There are two implementations for rounding. The first one requires a date time unit and rounds to the supplied date time unit (i.e. quarter of year, day of month). The second one allows you to specify an interval to round to.

See this blog for some background reading. Its super interesting and the links are a comedy gold mine. If you like time zones. Or hate them.

  • Constructor Details

    • Rounding

      public Rounding()
  • Method Details

    • innerWriteTo

      public abstract void innerWriteTo​(StreamOutput out) throws java.io.IOException
      Throws:
      java.io.IOException
    • writeTo

      public void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      java.io.IOException
    • id

      public abstract byte id()
    • prepare

      public abstract Rounding.Prepared prepare​(long minUtcMillis, long maxUtcMillis)
      Prepare to round many times.
    • prepareForUnknown

      public abstract Rounding.Prepared prepareForUnknown()
      Prepare to round many dates over an unknown range. Prefer prepare(long, long) if you can find the range because it'll be much more efficient.
    • round

      @Deprecated public final long round​(long utcMillis)
      Rounds the given value.
    • nextRoundingValue

      @Deprecated public final long nextRoundingValue​(long utcMillis)
      Given the rounded value (which was potentially generated by round(long), returns the next rounding value. For example, with interval based rounding, if the interval is 3, nextRoundValue(6) = 9.
    • offset

      @Deprecated public abstract long offset()
      Deprecated.
      We're in the process of abstracting offset *into* Rounding so keep any usage to migratory shims
      How "offset" this rounding is from the traditional "start" of the period.
    • withoutOffset

      public abstract Rounding withoutOffset()
      Strip the offset from these bounds.
    • equals

      public abstract boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public abstract int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • builder

      public static Rounding.Builder builder​(Rounding.DateTimeUnit unit)
    • builder

      public static Rounding.Builder builder​(org.elasticsearch.common.unit.TimeValue interval)
    • read

      public static Rounding read​(StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException