Documentation of 'org.jquantlib.time.Date' Java class
Date
org.jquantlib.time

Class Date

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Date>, Observable


    public class Date
    extends java.lang.Object
    implements Observable, java.lang.Comparable<Date>, java.io.Serializable, java.lang.Cloneable
    Date class to represent time in days.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Date()
      Default constructor returning a null date.
      Date(java.util.Date date)
      Allows interoperability with JDK Date
      Date(int day, int month, int year)
      More traditional constructor.
      Date(int day, Month month, int year)
      More traditional constructor.
      Date(long serialNumber)
      Constructor taking a serial number as given by Applix or Excel.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Date add(int days)
      returns a new date incremented by the given number of days
      Date add(Period period)
      returns a new date incremented by the given period
      Date addAssign(int days)
      increments this date by the given number of days
      Date addAssign(Period period)
      increments this date by the given period
      void addObserver(Observer observer)
      Attaches a observer to the Observable.
      Date clone() 
      int compareTo(Date o) 
      int countObservers()
      Counts how many Observers were attached to this class.
      int dayOfMonth() 
      int dayOfYear()
      One-based (Jan 1st = 1)
      Date dec()
      1-day post-decrement
      void deleteObserver(Observer observer)
      Detaches a previously attached observer to the observable.
      void deleteObservers()
      Detaches all previously attached observer to the observable.
      static Date endOfMonth(Date d)
      Last day of the month to which the given date belongs
      boolean eq(Date another) 
      boolean equals(java.lang.Object anObject) 
      boolean ge(Date another) 
      java.util.List<Observer> getObservers()
      Returns list of observers registered with the Observable.
      boolean gt(Date another) 
      int hashCode() 
      Date inc()
      1-day post-increment
      static boolean isEndOfMonth(Date d)
      Whether a date is the last day of its month
      static boolean isLeap(int year)
      Whether the given year is a leap one
      boolean isNull() 
      java.util.Date isoDate()
      Returns a java.util.Date configured for a ISO date formatter
      boolean isToday() 
      boolean le(Date another) 
      java.util.Date longDate()
      Retuirns a java.util.Date configured for a long date formatter
      static int lowerBound(java.util.List<Date> dates, Date value)
      This method is equivalent to std:lower_bound function Returns an index pointing to the first element in the ordered collection is equal or greater than passed value
      boolean lt(Date another) 
      static Date max(Date... t)
      Return the maximum Date in a range.
      static Date maxDate()
      Latest allowed date
      static Date min(Date... t)
      Return the minimum Date in a range.
      static Date minDate()
      Earliest allowed date
      Month month() 
      boolean ne(Date another) 
      static Date nextWeekday(Date d, Weekday w)
      Next given weekday following or equal to the given date
      void notifyObservers()
      Notifies all attached observers about changes in the observable.
      void notifyObservers(java.lang.Object arg)
      Notifies all attached observers about changes in the observable.
      static Date nthWeekday(int nth, Weekday dayOfWeek, int month, int year)
      Returns a new Date which is the n-th week day of a certain month/year
      static Date nthWeekday(int n, Weekday w, Month m, int y)
      n-th given weekday in the given month and year
      long serialNumber() 
      java.util.Date shortDate()
      Returns a java.util.Date configured for a short date formatter
      long sub(Date another)
      Difference in days between dates
      Date sub(int days)
      returns a new date decremented by the given number of days
      Date sub(Period period)
      returns a new date decremented by the given period
      Date subAssign(int days)
      decrement this date by the given number of days
      Date subAssign(Period period)
      decrements this date by the given period
      static Date todaysDate()
      Today's date.
      java.lang.String toString() 
      static int upperBound(java.util.List<Date> dates, Date value)
      This method is equivalent to C++ sdt:upper_bound function Returns an index pointing to the first element in the ordered collection which is greater than passed value
      Weekday weekday() 
      int year() 
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Date

        public Date()
        Default constructor returning a null date.
      • Date

        public Date(long serialNumber)
        Constructor taking a serial number as given by Applix or Excel.
        Parameters:
        serialNumber -
      • Date

        public Date(int day,
                    Month month,
                    int year)
        More traditional constructor.
        Parameters:
        d -
        moreGreeks -
        y -
      • Date

        public Date(int day,
                    int month,
                    int year)
        More traditional constructor.
        Parameters:
        d -
        moreGreeks -
        y -
      • Date

        public Date(java.util.Date date)
        Allows interoperability with JDK Date

        NOTE: Both java.util.Date and JQuantLib Date do not support time zones or high precision clocks. In other words, a day always has exactly 84,600 seconds, or 84,600,000 milliseconds.

    • Method Detail

      • weekday

        public Weekday weekday()
      • dayOfMonth

        public int dayOfMonth()
      • dayOfYear

        public int dayOfYear()
        One-based (Jan 1st = 1)
        Returns:
      • month

        public Month month()
      • year

        public int year()
      • serialNumber

        public long serialNumber()
      • addAssign

        public Date addAssign(int days)
        increments this date by the given number of days
        Returns:
        this
      • addAssign

        public Date addAssign(Period period)
        increments this date by the given period
        Returns:
        this
      • subAssign

        public Date subAssign(int days)
        decrement this date by the given number of days
        Returns:
        this
      • subAssign

        public Date subAssign(Period period)
        decrements this date by the given period
        Returns:
        this
      • inc

        public Date inc()
        1-day post-increment
        Returns:
        this
      • dec

        public Date dec()
        1-day post-decrement
        Returns:
        this
      • add

        public Date add(int days)
        returns a new date incremented by the given number of days
        Returns:
        a new instance
      • add

        public Date add(Period period)
        returns a new date incremented by the given period
        Returns:
        a new instance
      • sub

        public Date sub(int days)
        returns a new date decremented by the given number of days
        Returns:
        a new instance
      • sub

        public Date sub(Period period)
        returns a new date decremented by the given period
        Returns:
        a new instance
      • sub

        public long sub(Date another)
        Difference in days between dates
      • eq

        public boolean eq(Date another)
      • ne

        public boolean ne(Date another)
      • lt

        public boolean lt(Date another)
      • le

        public boolean le(Date another)
      • gt

        public boolean gt(Date another)
      • ge

        public boolean ge(Date another)
      • isNull

        public boolean isNull()
        Returns:
        true if this Date is null or non-valid date
      • isToday

        public final boolean isToday()
      • longDate

        public java.util.Date longDate()
        Retuirns a java.util.Date configured for a long date formatter

        Method toString would return something like Mon, dd yyyy

        Returns:
        a java.util.Date configured for a long date formatter
      • shortDate

        public java.util.Date shortDate()
        Returns a java.util.Date configured for a short date formatter

        Method toString would return something like mm/dd/yyyy

        Returns:
        a java.util.Date configured for a short date formatter
      • isoDate

        public java.util.Date isoDate()
        Returns a java.util.Date configured for a ISO date formatter

        Method toString would return something like yyyy-mm-yy

        Returns:
        a java.util.Date configured for a ISO date formatter
      • compareTo

        public int compareTo(Date o)
        Specified by:
        compareTo in interface java.lang.Comparable<Date>
      • addObserver

        public final void addObserver(Observer observer)
        Description copied from interface: Observable
        Attaches a observer to the Observable. After attachment the observer gets informed about changes in the Observable.
        Specified by:
        addObserver in interface Observable
        Parameters:
        observer - The observer to attach to the observable
      • countObservers

        public final int countObservers()
        Description copied from interface: Observable
        Counts how many Observers were attached to this class.
        Specified by:
        countObservers in interface Observable
        Returns:
        the number of Observers
        See Also:
        Observer
      • deleteObserver

        public final void deleteObserver(Observer observer)
        Description copied from interface: Observable
        Detaches a previously attached observer to the observable. After detachment the observer does no longer receive change notifications from the observable.
        Specified by:
        deleteObserver in interface Observable
        Parameters:
        observer - The observer to detach from the observable
      • notifyObservers

        public final void notifyObservers()
        Description copied from interface: Observable
        Notifies all attached observers about changes in the observable.
        Specified by:
        notifyObservers in interface Observable
      • notifyObservers

        public final void notifyObservers(java.lang.Object arg)
        Description copied from interface: Observable
        Notifies all attached observers about changes in the observable.
        Specified by:
        notifyObservers in interface Observable
        Parameters:
        arg - an arbitrary Object to be passed to the Observer
      • deleteObservers

        public final void deleteObservers()
        Description copied from interface: Observable
        Detaches all previously attached observer to the observable. After detachment observers do not longer receive change notifications from the observable.
        Specified by:
        deleteObservers in interface Observable
      • getObservers

        public final java.util.List<Observer> getObservers()
        Description copied from interface: Observable
        Returns list of observers registered with the Observable. List returned is unmodifiable list.
        Specified by:
        getObservers in interface Observable
        Returns:
        list of observers
      • hashCode

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

        public boolean equals(java.lang.Object anObject)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public Date clone()
        Overrides:
        clone in class java.lang.Object
      • todaysDate

        public static final Date todaysDate()
        Today's date.
        Returns:
        a new instance
      • minDate

        public static final Date minDate()
        Earliest allowed date
        Returns:
        a new instance
      • maxDate

        public static final Date maxDate()
        Latest allowed date
        Returns:
        a new instance
      • isLeap

        public static final boolean isLeap(int year)
        Whether the given year is a leap one
        Parameters:
        y -
        Returns:
      • endOfMonth

        public static final Date endOfMonth(Date d)
        Last day of the month to which the given date belongs
        Returns:
        a new instance
      • isEndOfMonth

        public static final boolean isEndOfMonth(Date d)
        Whether a date is the last day of its month
        Returns:
      • nextWeekday

        public static final Date nextWeekday(Date d,
                                             Weekday w)
        Next given weekday following or equal to the given date

        E.g., the Friday following Tuesday, JANUARY 15th, 2002 was JANUARY 18th, 2002.

        Returns:
        a new instance
        See Also:
        http://www.cpearson.com/excel/DateTimeWS.htm
      • nthWeekday

        public static final Date nthWeekday(int n,
                                            Weekday w,
                                            Month m,
                                            int y)
        n-th given weekday in the given month and year

        E.g., the 4th Thursday of March, 1998 was March 26th, 1998.

        Parameters:
        n -
        w -
        m -
        y -
        Returns:
        a new instance
        See Also:
        http://www.cpearson.com/excel/DateTimeWS.htm
      • nthWeekday

        public static final Date nthWeekday(int nth,
                                            Weekday dayOfWeek,
                                            int month,
                                            int year)
        Returns a new Date which is the n-th week day of a certain month/year
        Parameters:
        nth - is the desired week
        dayOfWeek - is the desired week day
        month - is the desired month
        year - is the desired year
        Returns:
        a new instance
      • min

        public static Date min(Date... t)
        Return the minimum Date in a range.
      • max

        public static Date max(Date... t)
        Return the maximum Date in a range.
      • lowerBound

        public static int lowerBound(java.util.List<Date> dates,
                                     Date value)
        This method is equivalent to std:lower_bound function Returns an index pointing to the first element in the ordered collection is equal or greater than passed value
        Parameters:
        dates - order collection in ascending order
        value - Date to be compared
        Returns:
        index to element which is >= passed value
      • upperBound

        public static int upperBound(java.util.List<Date> dates,
                                     Date value)
        This method is equivalent to C++ sdt:upper_bound function Returns an index pointing to the first element in the ordered collection which is greater than passed value
        Parameters:
        dates - order collection in ascending order
        value - Date to be compared
        Returns:
        index to element which is > passed value

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.