Class BrokerDate

java.lang.Object
COM.activesw.api.client.BrokerDate

public class BrokerDate extends Object
This class provides a powerful and flexible date/time system for use with the Java client API. It is intended to be used as a structure with publicly accessible fields, but methods are also provided to set these fields.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
     
    int
     
    boolean
    true if both date and time are represented.
    boolean
    true if the date and time are stored as UTC.
    int
     
    int
     
    int
     
    protected static final ResourceBundle
     
    int
     
    int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an empty date.
    BrokerDate(int yr, int mo, int dy)
    Create with the date set.
    BrokerDate(int yr, int mo, int dy, int hr, int m, int s, int ms)
    Create with the date and time set.
    BrokerDate(int yr, int mo, int dy, int hr, int m, int s, int ms, boolean normalize_time)
    Create with the date and time set.
    Copy constructor.
    BrokerDate(String date_string)
    Create from date string using the a date or date/time formatter for the US English locale.
    BrokerDate(String date_string, boolean normalize_time)
    Create from date string using the a date or date/time formatter for the US English locale.
    BrokerDate(String date_string, Locale locale)
    Create from date string using a date/time formatter for the specified locale.
    BrokerDate(String date_string, Locale locale, boolean normalize_time)
    Create from date string using a date/time formatter for the specified locale.
    BrokerDate(Calendar calendar)
    Create using a Java Calendar.
    BrokerDate(Calendar calendar, boolean normalize_time)
    Create using a Java Calendar.
    Create using a Java Date.
    BrokerDate(Date date, boolean normalize_time)
    Create using a Java Date.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the date entirely.
    void
    Clear the time but leave the date intact.
    int
    Compares to the given date.
    boolean
    True if the date is equal to this one.
    Get the date as a Java Calendar object.
    Get the date as a Java Date object.
    boolean
     
    static String
    msg(String key, String arg1)
     
    static BrokerDate
    parseDate(String date_string)
    Create a BrokerDate from a date string using a date or date/time formatter for the US English locale.
    static BrokerDate
    parseDate(String date_string, boolean normalize_time)
    Create a BrokerDate from a date string using a date or date/time formatter for the US English locale.
    static BrokerDate
    parseDate(String date_string, Locale locale)
    Create a BrokerDate from a date string using a date or date/time formatter for the specified locale.
    static BrokerDate
    parseDate(String date_string, Locale locale, boolean normalize_time)
    Create a BrokerDate from a date string using a date or date/time formatter for the specified locale.
    static BrokerDate
    Create a BrokerDate from a date string using a date or date/time formatter for the default locale.
    static BrokerDate
    parseLocalizedDate(String date_string, boolean normalize_time)
    Create a BrokerDate from a date string using a date or date/time formatter for the default locale.
    void
    setDate(int yr, int mo, int dy)
    Set the date only.
    void
    setDateTime(int yr, int mo, int dy, int hr, int m, int s, int ms)
    Set the date and time.
    void
    setDateTime(int yr, int mo, int dy, int hr, int m, int s, int ms, boolean normalize_time)
    Set the date and time.
    void
    Set from a Java Calendar object.
    void
    Set from a Java Date object.
    void
    setJavaDate(Date date, boolean normalize_time)
    Set from a Java Date object.
    void
    setTime(int hr, int m, int s, int ms)
    Set the time only.
    void
    setTime(int hr, int m, int s, int ms, boolean normalize_time)
    Set the time only.
    Return in a string format.
    Return in a string format.
    toString(Locale locale)
    Return in a string format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • rb

      protected static final ResourceBundle rb
    • year

      public int year
    • month

      public int month
    • day

      public int day
    • hour

      public int hour
    • min

      public int min
    • sec

      public int sec
    • msec

      public int msec
    • is_date_and_time

      public boolean is_date_and_time
      true if both date and time are represented. false if only a date is represented.
    • is_utc

      public boolean is_utc
      true if the date and time are stored as UTC. Introduced with 6.0.
  • Constructor Details

    • BrokerDate

      public BrokerDate()
      Create an empty date. 'is_date_and_time' is set to false. 'is_utc' is set to false.
    • BrokerDate

      public BrokerDate(int yr, int mo, int dy)
      Create with the date set. 'is_date_and_time' is set to false. 'is_utc' is set to false.
    • BrokerDate

      public BrokerDate(int yr, int mo, int dy, int hr, int m, int s, int ms)
      Create with the date and time set. 'is_date_and_time' is set to true. 'is_utc' is set to false.
    • BrokerDate

      public BrokerDate(int yr, int mo, int dy, int hr, int m, int s, int ms, boolean normalize_time)
      Create with the date and time set. 'is_date_and_time' is set to true. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. The time will be marked 'is_utc'.
    • BrokerDate

      public BrokerDate(Calendar calendar)
      Create using a Java Calendar. 'is_date_and_time' is set to true. 'is_utc' is set if the Calendar passed in is equivalent to UTC.
    • BrokerDate

      public BrokerDate(Calendar calendar, boolean normalize_time)
      Create using a Java Calendar. 'is_date_and_time' is set to true. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' is set to true.
    • BrokerDate

      public BrokerDate(Date date)
      Create using a Java Date. 'is_date_and_time' is set to true. 'is_utc' is set to false.
    • BrokerDate

      public BrokerDate(Date date, boolean normalize_time)
      Create using a Java Date. 'is_date_and_time' is set to true. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' is set to true.
    • BrokerDate

      public BrokerDate(BrokerDate date)
      Copy constructor.
    • BrokerDate

      public BrokerDate(String date_string) throws ParseException
      Create from date string using the a date or date/time formatter for the US English locale. The is_date_and_time flag will be set to true if minutes, seconds or milliseconds are all zero after parsing the script. On JDK versions 1.1.5 and earlier, JDK bugs result in some mis-parsed date values.
      Throws:
      ParseException - If there is an error in the date string.
    • BrokerDate

      public BrokerDate(String date_string, boolean normalize_time) throws ParseException
      Create from date string using the a date or date/time formatter for the US English locale. The is_date_and_time flag will be set to true if minutes, seconds or milliseconds are all zero after parsing the script. On JDK versions 1.1.5 and earlier, JDK bugs result in some mis-parsed date values.
      Throws:
      ParseException - If there is an error in the date string.
    • BrokerDate

      public BrokerDate(String date_string, Locale locale) throws ParseException
      Create from date string using a date/time formatter for the specified locale. The is_date_and_time flag will be set to true if minutes, seconds or milliseconds are all zero after parsing the script. On JDK versions 1.1.5 and earlier, JDK bugs result in some mis-parsed date values. 'is_utc' will be set to false.
      Throws:
      ParseException - If there is an error in the date string.
    • BrokerDate

      public BrokerDate(String date_string, Locale locale, boolean normalize_time) throws ParseException
      Create from date string using a date/time formatter for the specified locale. The is_date_and_time flag will be set to true if minutes, seconds or milliseconds are all zero after parsing the script. On JDK versions 1.1.5 and earlier, JDK bugs result in some mis-parsed date values. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' will be set to true.
      Throws:
      ParseException - If there is an error in the date string.
  • Method Details

    • parseDate

      public static BrokerDate parseDate(String date_string)
      Create a BrokerDate from a date string using a date or date/time formatter for the US English locale. Same as date constructor that takes a string, except this method does not throw ParseException if the conversion fails. Instead it throws an IllegalArgumentException. 'is_utc' will be set to false.
      Throws:
      IllegalArgumentException - If there is an error in the date string.
    • parseDate

      public static BrokerDate parseDate(String date_string, boolean normalize_time)
      Create a BrokerDate from a date string using a date or date/time formatter for the US English locale. Same as date constructor that takes a string, except this method does not throw ParseException if the conversion fails. Instead it throws an IllegalArgumentException. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' will be set to true.
      Throws:
      IllegalArgumentException - If there is an error in the date string.
    • parseDate

      public static BrokerDate parseDate(String date_string, Locale locale)
      Create a BrokerDate from a date string using a date or date/time formatter for the specified locale. Same as date constructor that takes a string, except this method does not throw ParseException if the conversion fails. Instead it throws an IllegalArgumentException. 'is_utc' will be set to false.
      Throws:
      IllegalArgumentException - If there is an error in the date string.
    • parseDate

      public static BrokerDate parseDate(String date_string, Locale locale, boolean normalize_time)
      Create a BrokerDate from a date string using a date or date/time formatter for the specified locale. Same as date constructor that takes a string, except this method does not throw ParseException if the conversion fails. Instead it throws an IllegalArgumentException. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' will be set to true.
      Throws:
      IllegalArgumentException - If there is an error in the date string.
    • parseLocalizedDate

      public static BrokerDate parseLocalizedDate(String date_string)
      Create a BrokerDate from a date string using a date or date/time formatter for the default locale. It is equivalent to calling parseDate(date_string, java.util.Locale.getDefault()). 'is_utc' will be set to false.
      Throws:
      IllegalArgumentException - If there is an error in the date string.
    • parseLocalizedDate

      public static BrokerDate parseLocalizedDate(String date_string, boolean normalize_time)
      Create a BrokerDate from a date string using a date or date/time formatter for the default locale. It is equivalent to calling parseDate(date_string, java.util.Locale.getDefault(), normalize_time). If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' will be set to true.
      Throws:
      IllegalArgumentException - If there is an error in the date string.
    • getJavaCalendar

      public Calendar getJavaCalendar() throws BrokerException
      Get the date as a Java Calendar object.
      Throws:
      BrokerOutOfRangeException - If the date in this object cannot be represetned in a Java Calendar.
      BrokerException
    • getJavaDate

      public Date getJavaDate() throws BrokerException
      Get the date as a Java Date object. Milisecond accuracy is lost.
      Throws:
      BrokerOutOfRangeException - If the date in this object cannot be represented in a Java Date.
      BrokerException
    • setDateTime

      public void setDateTime(int yr, int mo, int dy, int hr, int m, int s, int ms)
      Set the date and time. 'is_date_and_time' is set to true. 'is_utc' is set to false.
    • setDateTime

      public void setDateTime(int yr, int mo, int dy, int hr, int m, int s, int ms, boolean normalize_time)
      Set the date and time. 'is_date_and_time' is set to true. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' is set to true.
    • setDate

      public void setDate(int yr, int mo, int dy)
      Set the date only. Does not set 'is_utc'.
    • setTime

      public void setTime(int hr, int m, int s, int ms)
      Set the time only. 'is_date_and_time' is set to true. Does not set 'is_utc'.
    • setTime

      public void setTime(int hr, int m, int s, int ms, boolean normalize_time) throws BrokerException
      Set the time only. 'is_date_and_time' is set to true. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' is set to true.
      Throws:
      BrokerException
    • setJavaCalendar

      public void setJavaCalendar(Calendar calendar)
      Set from a Java Calendar object. 'is_date_and_time' is set to true. Sets 'is_utc' based on Calendar object's timezone being UTC.
    • setJavaDate

      public void setJavaDate(Date date)
      Set from a Java Date object. 'is_date_and_time' is set to true. 'is_utc' is set to false.
    • setJavaDate

      public void setJavaDate(Date date, boolean normalize_time)
      Set from a Java Date object. 'is_date_and_time' is set to true. If 'normalize_time' is true, the time will be converted into the UTC timezone from the local timezone. If 'normalize_time' is set to false, the time supplied is already in the UTC timezone. 'is_utc' is set to true.
    • clear

      public void clear()
      Clear the date entirely. 'is_date_and_time' is set to false. 'is_utc' is set to false.
    • clearTime

      public void clearTime()
      Clear the time but leave the date intact. 'is_date_and_time' is set to false. 'is_utc' is set to false if the resulting date isNull().
    • equals

      public boolean equals(BrokerDate d)
      True if the date is equal to this one.
    • compareTo

      public int compareTo(BrokerDate d)
      Compares to the given date. Returns 0 if this date equals, -1 if this date is less than, and 1 if this date is greater than the given date.
    • toString

      public String toString(Locale locale)
      Return in a string format. Uses the default date or date/time formatter for the specified locale.
    • toString

      public String toString()
      Return in a string format. Uses the default date or date/time formatter for the US English locale. Equivalent to toString(java.util.Locale.US)
      Overrides:
      toString in class Object
    • toLocalizedString

      public String toLocalizedString()
      Return in a string format. Convenience method that uses the date or date/time formatter for the default locale. Equivalent to toString(java.util.Locale.getDefault()).
    • msg

      public static String msg(String key, String arg1)
    • isNull

      public boolean isNull()