Class ApacheCommonsDateUtils

java.lang.Object
com.espertech.esper.common.internal.epl.datetime.calop.ApacheCommonsDateUtils

public class ApacheCommonsDateUtils extends Object

A suite of utilities surrounding the use of the Calendar and Date object.

DateUtils contains a lot of common methods considering manipulations of Dates or Calendars. Some methods require some extra explanation. The truncate, ceiling and round methods could be considered the Math.floor(), Math.ceil() or Math.round versions for dates This way date-FIELDS will be ignored in bottom-up order. As a complement to these methods we've introduced some fragment-methods. With these methods the Date-FIELDS will be ignored in top-down order. Since a date without a year is not a valid date, you have to decide in what kind of date-field you want your result, for instance milliseconds or days.

Since:
2.0
Version:
$Id: DateUtils.java 1056840 2011-01-09 00:12:23Z niallp $
Author:
Apache Software Foundation, Serge Knystautas, Janek Bogucki, Gary Gregory, Phil Steitz, Robert Scholte
  • Field Details

    • UTC_TIME_ZONE

      public static final TimeZone UTC_TIME_ZONE
      The UTC time zone (often referred to as GMT).
    • MILLIS_PER_SECOND

      public static final long MILLIS_PER_SECOND
      Number of milliseconds in a standard second.
      Since:
      2.1
      See Also:
    • MILLIS_PER_MINUTE

      public static final long MILLIS_PER_MINUTE
      Number of milliseconds in a standard minute.
      Since:
      2.1
      See Also:
    • MILLIS_PER_HOUR

      public static final long MILLIS_PER_HOUR
      Number of milliseconds in a standard hour.
      Since:
      2.1
      See Also:
    • MILLIS_PER_DAY

      public static final long MILLIS_PER_DAY
      Number of milliseconds in a standard day.
      Since:
      2.1
      See Also:
    • SEMI_MONTH

      public static final int SEMI_MONTH
      This is half a month, so this represents whether a date is in the top or bottom half of the month.
      See Also:
    • MODIFY_TRUNCATE

      public static final int MODIFY_TRUNCATE
      Constant marker for truncating
      See Also:
    • MODIFY_ROUND

      public static final int MODIFY_ROUND
      Constant marker for rounding
      See Also:
    • MODIFY_CEILING

      public static final int MODIFY_CEILING
      Constant marker for ceiling
      See Also:
  • Constructor Details

    • ApacheCommonsDateUtils

      public ApacheCommonsDateUtils()
  • Method Details

    • modify

      public static void modify(Calendar val, int field, int modType)

      Internal calculation method.

      Parameters:
      val - the calendar
      field - the field constant
      modType - type to truncate, round or ceiling
      Throws:
      ArithmeticException - if the year is over 280 million