com.bloomberglp.blpapi
Class Datetime

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

public final class Datetime
extends java.lang.Object
implements java.lang.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.

Author:
Siva Somu (ssomu)

Field Summary
static short DATE
           
static byte DAY_OF_MONTH
           
static byte HOUR
           
static short MICROSECOND
           
static byte MILLISECOND
           
static byte MINUTE
           
static byte MONTH
           
static short NANOSECOND
           
static short PICOSECOND
           
static byte SECOND
           
static short TIME
           
static byte TIME_ZONE_OFFSET
           
static short TIMEMILLI
           
static short YEAR
           
 
Constructor Summary
Datetime()
          Construct a Datetime object with each part initialized to an unset state
Datetime(java.util.Calendar calendar)
          Create Datetime object having the Date, Time and Timezone offset portions set to the specified values.
Datetime(Datetime other)
          construct a Datetime object having the same values as specified 'other' Datetime object
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.
 
Method Summary
 java.util.Calendar calendar()
          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 state
 java.lang.Object clone()
           
 int dayOfMonth()
          Return the day of month value of this Datetime object.
 boolean equals(java.lang.Object obj)
           
 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. use hasParts(int)
 int microsecond()
          Return the number of (whole) microseconds in the fraction-of-a-second part of the value of this object.
 int millisecond()
          Return the millisecond value within the second of this Datetime object.
 int milliSecond()
          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 nanosecond()
          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 picosecond()
          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 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(java.util.Calendar calendar)
          Set the Date, Time and TimezoneOffset portions of this Datetime object using values from the specified calendar.
 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 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 timezoneOffsetMinutes()
          Return the timezone offset value of this Datetime object.
 java.lang.String toString()
          Convert the Date and Time represented by this Datetime object to String.
 int year()
          Return the year value of this Datetime object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

YEAR

public static final short YEAR
See Also:
Constant Field Values

MONTH

public static final byte MONTH
See Also:
Constant Field Values

DAY_OF_MONTH

public static final byte DAY_OF_MONTH
See Also:
Constant Field Values

HOUR

public static final byte HOUR
See Also:
Constant Field Values

MINUTE

public static final byte MINUTE
See Also:
Constant Field Values

SECOND

public static final byte SECOND
See Also:
Constant Field Values

MILLISECOND

public static final byte MILLISECOND
See Also:
Constant Field Values

TIME_ZONE_OFFSET

public static final byte TIME_ZONE_OFFSET
See Also:
Constant Field Values

DATE

public static final short DATE
See Also:
Constant Field Values

TIME

public static final short TIME
See Also:
Constant Field Values

TIMEMILLI

public static final short TIMEMILLI
See Also:
Constant Field Values

MICROSECOND

public static final short MICROSECOND
See Also:
Constant Field Values

NANOSECOND

public static final short NANOSECOND
See Also:
Constant Field Values

PICOSECOND

public static final short PICOSECOND
See Also:
Constant Field Values
Constructor Detail

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(java.util.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 Detail

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 java.util.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

public boolean isValidField(int fieldId)
Deprecated. use hasParts(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 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(java.util.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(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

clone

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

toString

public java.lang.String toString()
Convert the Date and Time represented by this Datetime object to String.

Overrides:
toString in class java.lang.Object

hashCode

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


Copyright © 2015 Bloomberg L.P.. All Rights Reserved.