org.eclipse.birt.chart.util
Class CDateTime

java.lang.Object
  extended by com.ibm.icu.util.Calendar
      extended by com.ibm.icu.util.GregorianCalendar
          extended by org.eclipse.birt.chart.util.CDateTime
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class CDateTime
extends com.ibm.icu.util.GregorianCalendar

A convenience data type provided to aid in wrapping a datetime value used with datetime data elements. Refer to DateTimeDataElement

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.ibm.icu.util.Calendar
com.ibm.icu.util.Calendar.FormatConfiguration
 
Field Summary
 
Fields inherited from class com.ibm.icu.util.GregorianCalendar
AD, BC
 
Fields inherited from class com.ibm.icu.util.Calendar
AM, AM_PM, APRIL, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DOW_LOCAL, DST_OFFSET, ERA, EXTENDED_YEAR, FEBRUARY, FRIDAY, HOUR, HOUR_OF_DAY, JANUARY, JULIAN_DAY, JULY, JUNE, MARCH, MAY, MILLISECOND, MILLISECONDS_IN_DAY, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, WEEKDAY, WEEKEND, WEEKEND_CEASE, WEEKEND_ONSET, YEAR, YEAR_WOY, ZONE_OFFSET
 
Constructor Summary
CDateTime()
          A zero-arg default constructor
CDateTime(com.ibm.icu.util.Calendar c)
          A constructor that creates an instance from a given Calendar value
CDateTime(java.util.Date d)
          A constructor that creates an instance from a given java.util.Date value
CDateTime(int year, int month, int date)
          A constructor that creates an instance for a specified year, month and date
CDateTime(int year, int month, int date, int hour, int minute)
          A constructor that creates an instance for a specified year, month, date, hour and minute
CDateTime(int year, int month, int date, int hour, int minute, int second)
          A constructor that creates an instance for a specified year, month, date, hour and minute
CDateTime(java.util.Locale aLocale)
          Deprecated. use CDateTime(ULocale) instead.
CDateTime(long lTimeInMillis)
          A constructor that creates an instance from a given long value
CDateTime(com.ibm.icu.util.TimeZone tz)
          A constructor that creates a default instance for a given timezone
CDateTime(com.ibm.icu.util.TimeZone tz, java.util.Locale locale)
          Deprecated. use CDateTime(TimeZone, ULocale) instead.
CDateTime(com.ibm.icu.util.TimeZone tz, com.ibm.icu.util.ULocale locale)
          A constructor that creates a default instance for a given timezone and locale
CDateTime(com.ibm.icu.util.ULocale locale)
          A constructor that creates a default instance for a given locale
 
Method Summary
 boolean after(java.lang.Object when)
           
 CDateTime backward(int iUnit, int iStep)
          A convenient method used in building the ticks for a datetime scale.
 boolean before(java.lang.Object when)
           
 void clearBelow(int iUnit)
          Zeroes out all units for this datetime instance below a specified unit.
static double computeDifference(CDateTime cdt1, CDateTime cdt2, int iUnit)
          Computes the difference between two given datetime values as a fraction for the requested field.
static double computeDifference(CDateTime cdt1, CDateTime cdt2, int iUnit, boolean trimBelow)
          Computes the difference between two given datetime values as a fraction for the requested field.
static int computeUnit(CDateTime[] cdta)
          Walks through all values in a datetime array and computes the least significant unit for which a difference was noted.
static int computeUnit(org.eclipse.birt.chart.computation.DataSetIterator dsi)
          Walks through all values in a dataset and computes the least significant unit for which a difference was noted.
 CDateTime forward(int iUnit, int iStep)
          A convenient method used in building the ticks for a datetime scale.
 int getDay()
          Returns the day of the month associated with this instance
static int getDifference(CDateTime cdt1, CDateTime cdt2)
          Returns the most significant datetime unit in which there's a difference or 0 if there is no difference.
 int getHour()
          Returns the hour (military) associated with this instance
static int getMaximumDaysIn(int iYear)
          Returns the number of days for a particular year
static int getMaximumDaysIn(int iMonth, int iYear)
          Returns the number of days for a particular (month,year) combination
 int getMinute()
          Returns the minute associated with this instance
 int getMonth()
          Returns the month (0-based) associated with this instance
static java.lang.String getPreferredFormat(int iUnit)
          Returns a preferred format specifier for tick labels that represent axis values that will be computed based on the difference between cdt1 and cdt2
static int getPreferredUnit(CDateTime minDateTime, CDateTime maxDateTime)
          Returns a preferred format specifier for given data-time values will be computed based on the difference between minDateTime and maxDateTime
 int getSecond()
          Returns the second associated with this instance
 CDateTime getUnitStart(int iUnit)
          returns a CDateTime, whose value equals to the unit start of the current instance
 int getYear()
          Returns the year associated with this instance
static double inMillis(int iUnit)
          A convenience method provided to return the number of milliseconds available in a given unit
 boolean isTimeOnly()
          The property timeOnly indicates that this instance of CDateTime only represents a Time value, the Date value will be ignored.
static CDateTime parse(java.lang.String sDateTimeValue)
          Parses a value formatted as MM-dd-yyyy HH:mm:ss and attempts to create an instance of this object
 void setTimeOnly(boolean timeOnly)
          The property timeOnly indicates that this instance of CDateTime only represents a Time value, the Date value will be ignored.
 java.lang.String toString()
           
 
Methods inherited from class com.ibm.icu.util.GregorianCalendar
getActualMaximum, getActualMinimum, getGregorianChange, getType, hashCode, isEquivalentTo, isLeapYear, roll, setGregorianChange
 
Methods inherited from class com.ibm.icu.util.Calendar
add, clear, clear, clone, compareTo, compareTo, equals, fieldDifference, get, getAvailableLocales, getAvailableULocales, getDateTimeFormat, getDateTimeFormat, getDayOfWeekType, getDisplayName, getDisplayName, getFieldCount, getFirstDayOfWeek, getGreatestMinimum, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getLeastMaximum, getLocale, getMaximum, getMinimalDaysInFirstWeek, getMinimum, getTime, getTimeInMillis, getTimeZone, getWeekendTransition, isLenient, isSet, isWeekend, isWeekend, roll, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, setTimeZone
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CDateTime

public CDateTime()
A zero-arg default constructor


CDateTime

public CDateTime(java.util.Date d)
A constructor that creates an instance from a given java.util.Date value

Parameters:
d - A previously defined Date instance

CDateTime

public CDateTime(com.ibm.icu.util.Calendar c)
A constructor that creates an instance from a given Calendar value

Parameters:
c - A previously defined Calendar instance

CDateTime

public CDateTime(long lTimeInMillis)
A constructor that creates an instance from a given long value

Parameters:
lTimeInMillis - The time defined in milliseconds

CDateTime

public CDateTime(int year,
                 int month,
                 int date)
A constructor that creates an instance for a specified year, month and date

Parameters:
year - The year associated with this instance
month - The month index (1-12) of the year (1-based)
date - The day of the month associated with this instance

CDateTime

public CDateTime(int year,
                 int month,
                 int date,
                 int hour,
                 int minute)
A constructor that creates an instance for a specified year, month, date, hour and minute

Parameters:
year - The year associated with this instance
month - The month index (1-12) of the year (1-based)
date - The day of the month associated with this instance
hour - The hour (0-23) of the day (military) associated with this instance
minute - The minute (0-59) of the hour associated with this instance

CDateTime

public CDateTime(int year,
                 int month,
                 int date,
                 int hour,
                 int minute,
                 int second)
A constructor that creates an instance for a specified year, month, date, hour and minute

Parameters:
year - The year associated with this instance
month - The month index (1-12) of the year (1-based)
date - The day of the month associated with this instance
hour - The hour (0-23) of the day (military) associated with this instance
minute - The minute (0-59) of the hour associated with this instance
second - The second (0-59) of the minute associated with this instance

CDateTime

public CDateTime(java.util.Locale aLocale)
Deprecated. use CDateTime(ULocale) instead.

A constructor that creates a default instance for a given locale

Parameters:
locale - The locale for which the instance is being created

CDateTime

public CDateTime(com.ibm.icu.util.ULocale locale)
A constructor that creates a default instance for a given locale

Parameters:
locale - The locale for which the instance is being created
Since:
2.1

CDateTime

public CDateTime(com.ibm.icu.util.TimeZone tz)
A constructor that creates a default instance for a given timezone

Parameters:
tz - The timezone for which the instance is being created

CDateTime

public CDateTime(com.ibm.icu.util.TimeZone tz,
                 java.util.Locale locale)
Deprecated. use CDateTime(TimeZone, ULocale) instead.

A constructor that creates a default instance for a given timezone and locale

Parameters:
tz - The timezone for which the instance is being created
locale - The locale for which the instance is being created

CDateTime

public CDateTime(com.ibm.icu.util.TimeZone tz,
                 com.ibm.icu.util.ULocale locale)
A constructor that creates a default instance for a given timezone and locale

Parameters:
tz - The timezone for which the instance is being created
locale - The locale for which the instance is being created
Method Detail

backward

public CDateTime backward(int iUnit,
                          int iStep)
A convenient method used in building the ticks for a datetime scale. Computes a new datetime object relative to the existing one moving back by 'step' units.

Parameters:
iUnit -
iStep -
Returns:

forward

public CDateTime forward(int iUnit,
                         int iStep)
A convenient method used in building the ticks for a datetime scale. Computes a new datetime object relative to the existing one moving forward by 'step' units.

Parameters:
iUnit -
iStep -
Returns:

getYear

public final int getYear()
Returns the year associated with this instance

Returns:
The year associated with this instance

getMonth

public final int getMonth()
Returns the month (0-based) associated with this instance

Returns:
The month associated with this instance

getDay

public final int getDay()
Returns the day of the month associated with this instance

Returns:
The day of the month associated with this instance

getHour

public final int getHour()
Returns the hour (military) associated with this instance

Returns:
The hour associated with this instance

getMinute

public final int getMinute()
Returns the minute associated with this instance

Returns:
The minute associated with this instance

getSecond

public final int getSecond()
Returns the second associated with this instance

Returns:
The second associated with this instance

getDifference

public static final int getDifference(CDateTime cdt1,
                                      CDateTime cdt2)
Returns the most significant datetime unit in which there's a difference or 0 if there is no difference.

Returns:
The least significant 'Calendar' unit in which a difference occurred

getPreferredFormat

public static final java.lang.String getPreferredFormat(int iUnit)
Returns a preferred format specifier for tick labels that represent axis values that will be computed based on the difference between cdt1 and cdt2

Parameters:
iUnit - The unit for which a preferred pattern is being requested
Returns:
A preferred datetime format pattern for the given unit

getPreferredUnit

public static final int getPreferredUnit(CDateTime minDateTime,
                                         CDateTime maxDateTime)
Returns a preferred format specifier for given data-time values will be computed based on the difference between minDateTime and maxDateTime

Parameters:
minDateTime - The minimum data-time value
maxDateTime - The maximum data-time value
Returns:
A preferred datetime unit for the given values

computeDifference

public static final double computeDifference(CDateTime cdt1,
                                             CDateTime cdt2,
                                             int iUnit)
Computes the difference between two given datetime values as a fraction for the requested field.

Parameters:
cdt1 - The first datetime value
cdt2 - The second datetime value
iUnit - The field with respect to which the difference is being computed as a fraction
Returns:
The fractional difference between the two specified datetime values

computeDifference

public static final double computeDifference(CDateTime cdt1,
                                             CDateTime cdt2,
                                             int iUnit,
                                             boolean trimBelow)
Computes the difference between two given datetime values as a fraction for the requested field.

Parameters:
cdt1 - The first datetime value
cdt2 - The second datetime value
iUnit - The field with respect to which the difference is being computed as a fraction
trimBelow - Specifies if trim the unit below the given unit.
Returns:
The fractional difference between the two specified datetime values

computeUnit

public static final int computeUnit(org.eclipse.birt.chart.computation.DataSetIterator dsi)
Walks through all values in a dataset and computes the least significant unit for which a difference was noted.

Parameters:
dsi - The dataset iterator that facilitates visiting individual values
Returns:
The least significant unit for which a difference in datetime values was noted

computeUnit

public static final int computeUnit(CDateTime[] cdta)
                             throws ChartException
Walks through all values in a datetime array and computes the least significant unit for which a difference was noted.

Parameters:
cdta - A datetime array for which the least significant unit difference is to be computed
Returns:
The least significant unit for which a difference in datetime values was noted
Throws:
ChartException

getMaximumDaysIn

public static final int getMaximumDaysIn(int iMonth,
                                         int iYear)
Returns the number of days for a particular (month,year) combination

Parameters:
iMonth - The month (0-11) for which the day count is to be retrieved
iYear - The year for which the day count is to be retrieved
Returns:

getMaximumDaysIn

public static final int getMaximumDaysIn(int iYear)
Returns the number of days for a particular year

Parameters:
iYear - The year for which the day count is to be retrieved
Returns:
The number of days in the specified year

inMillis

public static final double inMillis(int iUnit)
A convenience method provided to return the number of milliseconds available in a given unit

Parameters:
iUnit - The unit for which the number of milliseconds are to be computed
Returns:
The number of milliseconds for the specified unit

clearBelow

public final void clearBelow(int iUnit)
Zeroes out all units for this datetime instance below a specified unit.

Parameters:
iUnit - The unit below which all values are to be zeroed out

getUnitStart

public CDateTime getUnitStart(int iUnit)
returns a CDateTime, whose value equals to the unit start of the current instance

Parameters:
iUnit -
Returns:

parse

public static CDateTime parse(java.lang.String sDateTimeValue)
Parses a value formatted as MM-dd-yyyy HH:mm:ss and attempts to create an instance of this object

Parameters:
sDateTimeValue - The value to be parsed
Returns:
An instance of the datetime value created

toString

public final java.lang.String toString()
Overrides:
toString in class com.ibm.icu.util.Calendar

after

public boolean after(java.lang.Object when)
Overrides:
after in class com.ibm.icu.util.Calendar

before

public boolean before(java.lang.Object when)
Overrides:
before in class com.ibm.icu.util.Calendar

isTimeOnly

public boolean isTimeOnly()
The property timeOnly indicates that this instance of CDateTime only represents a Time value, the Date value will be ignored.

Returns:
Returns the bTimeOnly.

setTimeOnly

public void setTimeOnly(boolean timeOnly)
The property timeOnly indicates that this instance of CDateTime only represents a Time value, the Date value will be ignored.

Parameters:
timeOnly - The bTimeOnly to set.


Copyright © 2005-2008 Actuate Corp. All rights reserved.