Package org.eclipse.birt.chart.util
Class CDateTime
java.lang.Object
com.ibm.icu.util.Calendar
com.ibm.icu.util.GregorianCalendar
org.eclipse.birt.chart.util.CDateTime
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<com.ibm.icu.util.Calendar>
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ibm.icu.util.Calendar
com.ibm.icu.util.Calendar.FormatConfiguration, com.ibm.icu.util.Calendar.WeekData
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
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, IS_LEAP_MONTH, JANUARY, JULIAN_DAY, JULY, JUNE, MARCH, MAY, MILLISECOND, MILLISECONDS_IN_DAY, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, ORDINAL_MONTH, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, WALLTIME_FIRST, WALLTIME_LAST, WALLTIME_NEXT_VALID, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, WEEKDAY, WEEKEND, WEEKEND_CEASE, WEEKEND_ONSET, YEAR, YEAR_WOY, ZONE_OFFSET
-
Constructor Summary
ConstructorsConstructorDescriptionA zero-arg default constructorCDateTime
(int year, int month, int date) A constructor that creates an instance for a specified year, month and dateCDateTime
(int year, int month, int date, int hour, int minute) A constructor that creates an instance for a specified year, month, date, hour and minuteCDateTime
(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 minuteCDateTime
(long lTimeInMillis) A constructor that creates an instance from a givenlong
valueCDateTime
(com.ibm.icu.util.Calendar c) A constructor that creates an instance from a givenCalendar
valueCDateTime
(com.ibm.icu.util.TimeZone tz) A constructor that creates a default instance for a given timezoneCDateTime
(com.ibm.icu.util.TimeZone tz, com.ibm.icu.util.ULocale locale) A constructor that creates a default instance for a given timezone and localeDeprecated.CDateTime
(com.ibm.icu.util.ULocale locale) A constructor that creates a default instance for a given localeA constructor that creates an instance from a givenjava.util.Date
value.Deprecated.useCDateTime(ULocale)
instead. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int unit, int step) boolean
backward
(int iUnit, int iStep) A convenient method used in building the ticks for a datetime scale.boolean
final void
clearAbove
(int iUnit) Reset all units for this datetime instance above a specified unit.final void
clearAbove
(int iUnit, boolean always) Reset all units for this datetime instance above a specified unit.final void
clearBelow
(int iUnit) Zeroes out all units for this datetime instance below a specified unit.final void
clearBelow
(int iUnit, boolean always) Zeroes out all units for this datetime instance below a specified unit.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.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.static final int
Walks through all values in a dataset and computes the least significant unit for which a difference was noted.static final int
computeUnit
(CDateTime[] cdta) Walks through all values in a datetime array and computes the least significant unit for which a difference was noted.forward
(int iUnit, int iStep) A convenient method used in building the ticks for a datetime scale.final int
getDay()
Returns the day of the month associated with this instancestatic 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.final int
getHour()
Returns the hour (military) associated with this instancestatic final int
getMaximumDaysIn
(int iYear) Returns the number of days for a particular yearstatic final int
getMaximumDaysIn
(int iMonth, int iYear) Returns the number of days for a particular (month,year) combinationfinal int
Returns the minute associated with this instancefinal int
getMonth()
Returns the month (0-based) associated with this instancestatic final 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 cdt2static 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 maxDateTimefinal int
Returns the second associated with this instancegetUnitStart
(int iUnit) returns a CDateTime, whose value equals to the unit start of the current instancefinal int
getYear()
Returns the year associated with this instancestatic final double
inMillis
(int iUnit) A convenience method provided to return the number of milliseconds available in a given unitboolean
Represents if current value has both Date and Time.boolean
The property timeOnly indicates that this instance of CDateTime only represents a Time value, the Date value will be ignored.static CDateTime
Parses a value formatted as MM-dd-yyyy HH:mm:ss and attempts to create an instance of this objectvoid
setTimeOnly
(boolean timeOnly) The property timeOnly indicates that this instance of CDateTime only represents a Time value, the Date value will be ignored.final 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
clear, clear, clone, compareTo, equals, fieldDifference, get, getAvailableLocales, getAvailableULocales, getDateAtTimePattern, getDateTimeFormat, getDateTimeFormat, getDateTimePattern, getDayOfWeekType, getDisplayName, getDisplayName, getFieldCount, getFirstDayOfWeek, getGreatestMinimum, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getKeywordValuesForLocale, getLeastMaximum, getLocale, getMaximum, getMinimalDaysInFirstWeek, getMinimum, getRelatedYear, getRepeatedWallTimeOption, getSkippedWallTimeOption, getTemporalMonthCode, getTime, getTimeInMillis, getTimeZone, getWeekData, getWeekDataForRegion, getWeekendTransition, haveDefaultCentury, inTemporalLeapYear, isLenient, isSet, isWeekend, isWeekend, roll, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setRelatedYear, setRepeatedWallTimeOption, setSkippedWallTimeOption, setTemporalMonthCode, setTime, setTimeInMillis, setTimeZone, setWeekData
-
Field Details
-
QUARTER
public static final int QUARTER- See Also:
-
WEEK_OF_QUARTER
public static final int WEEK_OF_QUARTER- See Also:
-
DAY_OF_QUARTER
public static final int DAY_OF_QUARTER- See Also:
-
-
Constructor Details
-
CDateTime
public CDateTime()A zero-arg default constructor -
CDateTime
A constructor that creates an instance from a givenjava.util.Date
value. If it's an instance ofjava.sql.Date
, it's Date only data. If it's an instance ofjava.sql.Time
, it's Time only data. Otherwise, it means full date time 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 givenCalendar
value- Parameters:
c
- A previously defined Calendar instance
-
CDateTime
public CDateTime(long lTimeInMillis) A constructor that creates an instance from a givenlong
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 instancemonth
- 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 instancemonth
- The month index (1-12) of the year (1-based)date
- The day of the month associated with this instancehour
- The hour (0-23) of the day (military) associated with this instanceminute
- 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 instancemonth
- The month index (1-12) of the year (1-based)date
- The day of the month associated with this instancehour
- The hour (0-23) of the day (military) associated with this instanceminute
- The minute (0-59) of the hour associated with this instancesecond
- The second (0-59) of the minute associated with this instance
-
CDateTime
Deprecated.useCDateTime(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
Deprecated.useCDateTime(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 createdlocale
- 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 createdlocale
- The locale for which the instance is being created
-
-
Method Details
-
backward
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:
- new instance
-
forward
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:
- new instance
-
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
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
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
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 valuemaxDateTime
- The maximum data-time value- Returns:
- A preferred datetime unit for the given values
-
computeDifference
Computes the difference between two given datetime values as a fraction for the requested field.- Parameters:
cdt1
- The first datetime valuecdt2
- The second datetime valueiUnit
- 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 valuecdt2
- The second datetime valueiUnit
- The field with respect to which the difference is being computed as a fractiontrimBelow
- Specifies if trim the unit below the given unit.- Returns:
- The fractional difference between the two specified datetime values
-
computeUnit
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
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 retrievediYear
- The year for which the day count is to be retrieved- Returns:
- number of days
-
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. If it's full date time, no trim because original value should be used to format using time zone.- Parameters:
iUnit
- The unit below which all values are to be zeroed out
-
clearBelow
public final void clearBelow(int iUnit, boolean always) Zeroes out all units for this datetime instance below a specified unit.- Parameters:
iUnit
- The unit below which all values are to be zeroed outalways
- indicates if it's always trimmed no matter if it's full date time
-
clearAbove
public final void clearAbove(int iUnit) Reset all units for this datetime instance above a specified unit.- Parameters:
iUnit
- The unit above which year values are to be reset
-
clearAbove
public final void clearAbove(int iUnit, boolean always) Reset all units for this datetime instance above a specified unit.- Parameters:
iUnit
- The unit above which year values are to be resetalways
- indicates if it's always trimmed no matter if it's full date time
-
getUnitStart
returns a CDateTime, whose value equals to the unit start of the current instance- Parameters:
iUnit
-- Returns:
- new instance
-
parse
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
- Overrides:
toString
in classcom.ibm.icu.util.Calendar
-
after
- Overrides:
after
in classcom.ibm.icu.util.Calendar
-
before
- Overrides:
before
in classcom.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:
- true if time only.
-
isFullDateTime
public boolean isFullDateTime()Represents if current value has both Date and Time. If yes, Timezone will be considered during formatting.- Returns:
- true if current value has both Date and Time
-
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.
-
add
public void add(int unit, int step) - Overrides:
add
in classcom.ibm.icu.util.Calendar
-
getDateTime
-
CDateTime(TimeZone, ULocale)
instead.