Package com.bloomberglp.blpapi
Class Datetime
java.lang.Object
com.bloomberglp.blpapi.Datetime
- All Implemented Interfaces:
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
Modifier and TypeFieldDescriptionstatic 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
ConstructorDescriptionDatetime()
Construct a Datetime object with each part initialized to an unset stateDatetime
(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 objectCreate Datetime object having the Date, Time and Timezone offset portions set to the specified values. -
Method Summary
Modifier and TypeMethodDescriptioncalendar()
Return the Date, Time and Timezone offset represented by this Datetime object as a Java Calendar.void
clear()
Set all parts of this Datetime object to the unset stateclone()
int
Return the day of month value of this Datetime object.boolean
int
hashCode()
boolean
hasParts
(int parts) Return true if this Datetime object has all of the specified parts set.int
hour()
Return the hour value of this Datetime object.boolean
isValid()
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
minute()
Return the minute value of this Datetime object.int
month()
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
parts()
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
second()
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 valuesvoid
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 valuesvoid
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 valuesvoid
setDatetimeTz
(Calendar calendar) 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 valuesvoid
setDayOfMonth
(int dayOfMonth) set the day of month value of this Datetime object to the specified dayOfMonthvoid
setHour
(int hour) set the hour value of this Datetime object to the specified hourvoid
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 minutevoid
setMonth
(int month) set the month value of this Datetime object to the specified monthvoid
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 secondvoid
setTime
(int hour, int minute, int second, int millisecond) Set the time portions of this Datetime object to the specified valuesvoid
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 valuesvoid
setTimezoneOffsetMinutes
(int timezoneOffsetMinutes) set the timezone offset value of this Datetime object to the specified timezoneOffsetMinutesvoid
setYear
(int year) set the year value of this Datetime object to the specified yearint
Return the timezone offset value of this Datetime object.toString()
Convert the Date and Time represented by this Datetime object to String.int
year()
Return the year value of this Datetime object.
-
Field Details
-
YEAR
public static final short YEAR- See Also:
-
MONTH
public static final byte MONTH- See Also:
-
DAY_OF_MONTH
public static final byte DAY_OF_MONTH- See Also:
-
HOUR
public static final byte HOUR- See Also:
-
MINUTE
public static final byte MINUTE- See Also:
-
SECOND
public static final byte SECOND- See Also:
-
MILLISECOND
public static final byte MILLISECOND- See Also:
-
TIME_ZONE_OFFSET
public static final byte TIME_ZONE_OFFSET- See Also:
-
DATE
public static final short DATE- See Also:
-
TIME
public static final short TIME- See Also:
-
TIMEMILLI
public static final short TIMEMILLI- See Also:
-
MICROSECOND
public static final short MICROSECOND- See Also:
-
NANOSECOND
public static final short NANOSECOND- See Also:
-
PICOSECOND
public static final short PICOSECOND- See Also:
-
-
Constructor Details
-
Datetime
public Datetime()Construct a Datetime object with each part initialized to an unset state -
Datetime
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 yearmonth
- the month between 1-12dayOfMonth
- the day of the month between 1-31hour
- the hour of the day between 0-23minute
- the minute between 0-59second
- the second between 0-59millisecond
- 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 yearmonth
- the month between 1-12dayOfMonth
- 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-23minute
- the minute between 0-59second
- the second between 0-59millisecond
- the millisecond between 0-999
-
Datetime
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
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.usehasParts(int)
-
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 yearmonth
- the month between 1-12dayOfMonth
- the day of the month between 1-31hour
- the hour of the day between 0-23minute
- the minute between 0-59second
- the second between 0-59millisecond
- 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 yearmonth
- the month between 1-12dayOfMonth
- the day of the month between 1-31hour
- the hour of the day between 0-23minute
- the minute between 0-59second
- the second between 0-59millisecond
- the millisecond between 0-999timezoneOffsetMinutes
- 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 yearmonth
- the month between 1-12dayOfMonth
- 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 yearmonth
- the month between 1-12dayOfMonth
- the day of the month between 1-31timezoneOffsetMinutes
- 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-23minute
- the minute between 0-59second
- the second between 0-59millisecond
- 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-23minute
- the minute between 0-59second
- the second between 0-59millisecond
- the millisecond between 0-999timezoneOffsetMinutes
- the timezone offset in minutes
-
setDatetimeTz
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
-
clone
-
toString
Convert the Date and Time represented by this Datetime object to String. -
hashCode
public int hashCode()
-
hasParts(int)