Class Datetime

java.lang.Object
com.bloomberglp.blpapi.Datetime
All Implemented Interfaces:
Cloneable

public final class Datetime extends Object implements Cloneable
Represents a date and/or time

Datetime can represent a date and/or a time or any combination of the components of a date and time. The value is represented as eight parts which can be set or queried independently. These parts are: year; month; day (of month); hour; minute; second; milliseconds and offset (of timezone from GMT in minutes). Methods are provided to set and query the parts individually and in groups. For example, setDate() and setTime(). It is also possible to determine which parts of the Datetime have been set.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final short
     
    static final byte
     
    static final byte
     
    static final short
     
    static final byte
     
    static final byte
     
    static final byte
     
    static final short
     
    static final short
     
    static final byte
     
    static final short
     
    static final byte
     
    static final short
     
    static final short
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a Datetime object with each part initialized to an unset state
    Datetime(int year, int month, int dayOfMonth)
    Create Datetime object having the Date portion set to the specified values.
    Datetime(int hour, int minute, int second, int millisecond)
    Create Datetime object having the Time portion set to the specified values.
    Datetime(int year, int month, int dayOfMonth, int hour, int minute, int second, int millisecond)
    Create Datetime object having the Date and Time portions set to the specified values.
    construct a Datetime object having the same values as specified 'other' Datetime object
    Datetime(Calendar calendar)
    Create Datetime object having the Date, Time and Timezone offset portions set to the specified values.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the Date, Time and Timezone offset represented by this Datetime object as a Java Calendar.
    void
    Set all parts of this Datetime object to the unset state
     
    int
    Return the day of month value of this Datetime object.
    boolean
     
    int
     
    boolean
    hasParts(int parts)
    Return true if this Datetime object has all of the specified parts set.
    int
    Return the hour value of this Datetime object.
    boolean
    Check whether the value of this 'Datetime' object is valid.
    boolean
    isValidField(int fieldId)
    Deprecated.
    int
    Return the number of (whole) microseconds in the fraction-of-a-second part of the value of this object.
    int
    Return the millisecond value within the second of this Datetime object.
    int
    Return the millisecond value within the second of this Datetime object.
    int
    Return the minute value of this Datetime object.
    int
    Return the month value of this Datetime object.
    int
    Return the number of (whole) nanoseconds in the fraction-of-a-second part of the value of this object.
    int
    Return a bitmask of all parts that are set in this Datetime object.
    long
    Return the number of (whole) picoseconds in the fraction-of-a-second part of the value of this object.
    int
    Return the second value of this Datetime object.
    void
    setDate(int year, int month, int dayOfMonth)
    Set the date portion of this Datetime object to the specified values
    void
    setDatetime(int year, int month, int dayOfMonth, int hour, int minute, int second, int millisecond)
    Set the date, time and portions of this Datetime object to the specified values
    void
    setDatetimeTz(int year, int month, int dayOfMonth, int hour, int minute, int second, int millisecond, int timezoneOffsetMinutes)
    Set the date, time and timezone offset portions of this Datetime object to the specified values
    void
    Set the Date, Time and TimezoneOffset portions of this Datetime object using values from the specified calendar.
    void
    setDateTz(int year, int month, int dayOfMonth, int timezoneOffsetMinutes)
    Set the date and timezone offset portions of this Datetime object to the specified values
    void
    setDayOfMonth(int dayOfMonth)
    set the day of month value of this Datetime object to the specified dayOfMonth
    void
    setHour(int hour)
    set the hour value of this Datetime object to the specified hour
    void
    setMicrosecond(int microsecond)
    set the fraction of a second of this Datetime object to the specified microsecond.
    void
    setMillisecond(int millisecond)
    set the millisecond value within the second of this Datetime object to the specified milliSecond.
    void
    setMilliSecond(int millisecond)
    set the millisecond value within the second of this Datetime object to the specified millisecond.
    void
    setMinute(int minute)
    set the minute value of this Datetime object to the specified minute
    void
    setMonth(int month)
    set the month value of this Datetime object to the specified month
    void
    setNanosecond(int nanosecond)
    set the fraction of a second of this Datetime object to the specified nanosecond.
    void
    setPicosecond(long picosecond)
    set the fraction of a second of this Datetime object to the specified picosecond.
    void
    setSecond(int second)
    set the second of this Datetime object to the specified second
    void
    setTime(int hour, int minute, int second, int millisecond)
    Set the time portions of this Datetime object to the specified values
    void
    setTimeTz(int hour, int minute, int second, int millisecond, int timezoneOffsetMinutes)
    Set the time and timezone offset portions of this Datetime object to the specified values
    void
    setTimezoneOffsetMinutes(int timezoneOffsetMinutes)
    set the timezone offset value of this Datetime object to the specified timezoneOffsetMinutes
    void
    setYear(int year)
    set the year value of this Datetime object to the specified year
    int
    Return the timezone offset value of this Datetime object.
    Convert the Date and Time represented by this Datetime object to String.
    int
    Return the year value of this Datetime object.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Datetime

      public Datetime()
      Construct a Datetime object with each part initialized to an unset state
    • Datetime

      public Datetime(Datetime other)
      construct a Datetime object having the same values as specified 'other' Datetime object
      Parameters:
      other - the Datetime object to copy
    • Datetime

      public Datetime(int year, int month, int dayOfMonth, int hour, int minute, int second, int millisecond)
      Create Datetime object having the Date and Time portions set to the specified values. The timezone offset is in the unset state
      Parameters:
      year - the year
      month - the month between 1-12
      dayOfMonth - the day of the month between 1-31
      hour - the hour of the day between 0-23
      minute - the minute between 0-59
      second - the second between 0-59
      millisecond - the millisecond between 0-999
    • Datetime

      public Datetime(int year, int month, int dayOfMonth)
      Create Datetime object having the Date portion set to the specified values. The time and timezone offset are in the unset state
      Parameters:
      year - the year
      month - the month between 1-12
      dayOfMonth - the day of the month between 1-31
    • Datetime

      public Datetime(int hour, int minute, int second, int millisecond)
      Create Datetime object having the Time portion set to the specified values. The Date and timezone offset are in the unset state
      Parameters:
      hour - the hour of the day between 0-23
      minute - the minute between 0-59
      second - the second between 0-59
      millisecond - the millisecond between 0-999
    • Datetime

      public Datetime(Calendar calendar)
      Create Datetime object having the Date, Time and Timezone offset portions set to the specified values.
      Parameters:
      calendar - the calendar object whose values are to be used to construct a new Datetime
  • Method Details

    • year

      public int year()
      Return the year value of this Datetime object. The result is undefined unless this object has a year value set
    • month

      public int month()
      Return the month value of this Datetime object. The result is undefined unless this object has a month value set
    • dayOfMonth

      public int dayOfMonth()
      Return the day of month value of this Datetime object. The result is undefined unless this object has a day of month value set
    • hour

      public int hour()
      Return the hour value of this Datetime object. The result is undefined unless this object has a hour value set
    • minute

      public int minute()
      Return the minute value of this Datetime object. The result is undefined unless this object has a minute value set
    • second

      public int second()
      Return the second value of this Datetime object. The result is undefined unless this object has a second value set
    • milliSecond

      public int milliSecond()
      Return the millisecond value within the second of this Datetime object. The result is undefined unless this object has a millisecond value set
    • millisecond

      public int millisecond()
      Return the millisecond value within the second of this Datetime object. The result is undefined unless this object has a millisecond value set
    • microsecond

      public int microsecond()
      Return the number of (whole) microseconds in the fraction-of-a-second part of the value of this object. The result is undefined unless object has a microsecond value set.
    • nanosecond

      public int nanosecond()
      Return the number of (whole) nanoseconds in the fraction-of-a-second part of the value of this object. The result is undefined unless object has a nanosecond value set.
    • picosecond

      public long picosecond()
      Return the number of (whole) picoseconds in the fraction-of-a-second part of the value of this object. The result is undefined unless object has a picosecond value set.
    • timezoneOffsetMinutes

      public int timezoneOffsetMinutes()
      Return the timezone offset value of this Datetime object. The result is undefined unless this object has a timezone offset value set
    • calendar

      public Calendar calendar()
      Return the Date, Time and Timezone offset represented by this Datetime object as a Java Calendar. The Timezone of the returned Calendar object is always set to UTC and the time represented by this Datetime object is converted to UTC.
    • isValidField

      @Deprecated public boolean isValidField(int fieldId)
      Deprecated.
    • parts

      public int parts()
      Return a bitmask of all parts that are set in this Datetime object. This can be compared to the values in the Datetime Parts constants using bitwise operations.
    • hasParts

      public boolean hasParts(int parts)
      Return true if this Datetime object has all of the specified parts set. The parts parameter must be constructed by or-ing together values in the DateTime Parts constants.
      Parameters:
      parts - the bitmap identifying which parts of this Datetime object needs to be tested
    • isValid

      public boolean isValid()
      Check whether the value of this 'Datetime' object is valid. The behaviour is undefined unless this object represents a date (has YEAR, MONTH and DAY part set) or time (has HOURS, MINUTES, SECONDS and MILLISECONDS part set).
    • setDatetime

      public void setDatetime(int year, int month, int dayOfMonth, int hour, int minute, int second, int millisecond)
      Set the date, time and portions of this Datetime object to the specified values
      Parameters:
      year - the year
      month - the month between 1-12
      dayOfMonth - the day of the month between 1-31
      hour - the hour of the day between 0-23
      minute - the minute between 0-59
      second - the second between 0-59
      millisecond - the millisecond between 0-999
    • setDatetimeTz

      public void setDatetimeTz(int year, int month, int dayOfMonth, int hour, int minute, int second, int millisecond, int timezoneOffsetMinutes)
      Set the date, time and timezone offset portions of this Datetime object to the specified values
      Parameters:
      year - the year
      month - the month between 1-12
      dayOfMonth - the day of the month between 1-31
      hour - the hour of the day between 0-23
      minute - the minute between 0-59
      second - the second between 0-59
      millisecond - the millisecond between 0-999
      timezoneOffsetMinutes - the timezone offset in minutes
    • setDate

      public void setDate(int year, int month, int dayOfMonth)
      Set the date portion of this Datetime object to the specified values
      Parameters:
      year - the year
      month - the month between 1-12
      dayOfMonth - the day of the month between 1-31
    • setDateTz

      public void setDateTz(int year, int month, int dayOfMonth, int timezoneOffsetMinutes)
      Set the date and timezone offset portions of this Datetime object to the specified values
      Parameters:
      year - the year
      month - the month between 1-12
      dayOfMonth - the day of the month between 1-31
      timezoneOffsetMinutes - the timezone offset in minutes
    • setTime

      public void setTime(int hour, int minute, int second, int millisecond)
      Set the time portions of this Datetime object to the specified values
      Parameters:
      hour - the hour of the day between 0-23
      minute - the minute between 0-59
      second - the second between 0-59
      millisecond - the millisecond between 0-999
    • setTimeTz

      public void setTimeTz(int hour, int minute, int second, int millisecond, int timezoneOffsetMinutes)
      Set the time and timezone offset portions of this Datetime object to the specified values
      Parameters:
      hour - the hour of the day between 0-23
      minute - the minute between 0-59
      second - the second between 0-59
      millisecond - the millisecond between 0-999
      timezoneOffsetMinutes - the timezone offset in minutes
    • setDatetimeTz

      public void setDatetimeTz(Calendar calendar)
      Set the Date, Time and TimezoneOffset portions of this Datetime object using values from the specified calendar.
      Parameters:
      calendar - the calendar object whose values are to be used to construct a new Datetime
    • setYear

      public void setYear(int year)
      set the year value of this Datetime object to the specified year
      Parameters:
      year -
    • setMonth

      public void setMonth(int month)
      set the month value of this Datetime object to the specified month
      Parameters:
      month -
    • setDayOfMonth

      public void setDayOfMonth(int dayOfMonth)
      set the day of month value of this Datetime object to the specified dayOfMonth
      Parameters:
      dayOfMonth -
    • setHour

      public void setHour(int hour)
      set the hour value of this Datetime object to the specified hour
      Parameters:
      hour -
    • setMinute

      public void setMinute(int minute)
      set the minute value of this Datetime object to the specified minute
      Parameters:
      minute -
    • setSecond

      public void setSecond(int second)
      set the second of this Datetime object to the specified second
      Parameters:
      second -
    • setMilliSecond

      public void setMilliSecond(int millisecond)
      set the millisecond value within the second of this Datetime object to the specified millisecond.
      Parameters:
      millisecond -
    • setMillisecond

      public void setMillisecond(int millisecond)
      set the millisecond value within the second of this Datetime object to the specified milliSecond.
      Parameters:
      millisecond -
    • setMicrosecond

      public void setMicrosecond(int microsecond)
      set the fraction of a second of this Datetime object to the specified microsecond. The behavior is undefined unless '0 <= microsecond <= 999999 us'.
      Parameters:
      microsecond -
    • setNanosecond

      public void setNanosecond(int nanosecond)
      set the fraction of a second of this Datetime object to the specified nanosecond. The behavior is undefined unless '0 <= nanosecond <= 999,999,999 ns'.
      Parameters:
      nanosecond -
    • setPicosecond

      public void setPicosecond(long picosecond)
      set the fraction of a second of this Datetime object to the specified picosecond. The behavior is undefined unless '0 <= picosecond <= 999,999,999,999 ns'
      Parameters:
      picosecond -
    • setTimezoneOffsetMinutes

      public void setTimezoneOffsetMinutes(int timezoneOffsetMinutes)
      set the timezone offset value of this Datetime object to the specified timezoneOffsetMinutes
      Parameters:
      timezoneOffsetMinutes -
    • clear

      public void clear()
      Set all parts of this Datetime object to the unset state
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • clone

      public Object clone()
    • toString

      public String toString()
      Convert the Date and Time represented by this Datetime object to String.
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object