com.crystaldecisions.reports.common.value
Class TimeValue

java.lang.Object
  extended byCrystalValue
      extended bycom.crystaldecisions.reports.common.value.FormulaValue
          extended bycom.crystaldecisions.reports.common.value.TimeValue
All Implemented Interfaces:
java.lang.Comparable

public class TimeValue
extends FormulaValue
implements java.lang.Comparable

Provides methods for converting native Java types to a format understood by the Crystal Reports Formula Language. All Java user defined functions must return a FormulaValue object.

See Also:
Serialized Form

Field Summary
static int hoursPerDay
           The number of hours per day is 24.
static TimeValue max
           The maximum TimeValue = t(23:59:59.999999999)
static long maxTimeInNs
           The maximum time in nanoseconds is one less than the total number of nanoseconds in a day (nanosecondsPerDay - 1).
static TimeValue min
           The minimum TimeValue = t(00:00:00.000000000)
static long minTimeInNs
           The minimum time in nanoseconds is 0.
static int minutesPerHour
           The number of minutes per hour is 60.
static long nanosecondsPerDay
           The number of nanoseconds per day.
static long nanosecondsPerHour
           The number of nanoseconds per hour.
static int nanosecondsPerMillisecond
           The number of nanoseconds per millisecond is 1000000.
static long nanosecondsPerMinute
           The number of nanoseconds per minute.
static long nanosecondsPerSecond
           The number of nanoseconds per second is 1000000000.
static int nullCRTime
           A null CRTime value.
static int secondsPerMinute
           The number of seconds per minute is 60.
 
Method Summary
 TimeValue addNumberToTime(double nSeconds)
           Add nSeconds seconds to the current time.
 FormulaValue coerceToDateTime()
           Internal use only.
 FormulaValue coerceToTime()
           Internal use only.
 int compareTo(java.lang.Object obj)
           Internal use only.
 int compareTo(java.lang.Object obj, java.util.Comparator stringComparator)
           Internal use only.
 boolean equals(java.lang.Object obj)
           Determines whether the parameter Object is a TimeValue object with the same class and value as this object.
static TimeValue fromCalendar(java.util.Calendar calendar)
           Returns a TimeValue object that represents the time in the specified Calendar object.
static TimeValue fromCRTime(int CRTime)
           Internal use only.
static TimeValue fromHMS(int hours, int minutes, double seconds)
           Returns a TimeValue object that represents the given hours, minutes and seconds parameters.
static TimeValue fromHMSN(int hours, int minutes, int seconds, long nanoseconds)
           Returns a TimeValue object that represents the given hours, minutes, seconds, and nanoseconds parameters.
static TimeValue fromOleDate(double OleDate)
           Internal use only.
static TimeValue fromTimeInNs(long timeInNs)
           Returns a TimeValue object that represents the given timeInNS.
 int getCRTime()
           Internal use only.
static int getCRTime(TimeValue time)
           Internal use only.
 int getHours()
           Gets the hours component of this TimeValue object.
 int getMinutes()
           Gets the minutes component of this TimeValue object.
 long getNanoseconds()
           Gets the nanoseconds component of this TimeValue object.
 double getOleDate()
           Internal use only.
 double getSeconds()
           Gets the seconds component of this TimeValue object.
 long getTimeInNs()
           Gets the time in nanoseconds from this TimeValue object.
 ValueType getValueType()
           Returns the ValueType of this TimeValue object.
 int getWholeSeconds()
           Gets the seconds component of this TimeValue object.
 int hashCode()
           Returns a hash code for this TimeValue object.
static long NormalizeTimeInNs(long timeInNs)
           Returns a normalized time value represented in nanoseconds.
static TimeValue now()
           Returns a TimeValue object that represents the current time when the method is called.
static double To1900Format(TimeValue time)
           Returns a double that represents the time in the 1900 format system (the fraction of the day completed since midnight).
 java.lang.String toString()
           Returns a String representation of this TimeValue object.
 
Methods inherited from class com.crystaldecisions.reports.common.value.FormulaValue
coerce, coerceToArray, coerceToArray, coerceToBoolean, coerceToBoolean, coerceToCurrency, coerceToCurrency, coerceToDate, coerceToDate, coerceToDateTime, coerceToNumber, coerceToNumber, coerceToRange, coerceToRange, coerceToRangeArray, coerceToRangeArray, coerceToString, coerceToString, coerceToTime, getFormulaValueType, makeZeroValue
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

nullCRTime

public static final int nullCRTime

A null CRTime value.

See Also:
Constant Field Values

hoursPerDay

public static final int hoursPerDay

The number of hours per day is 24.

See Also:
Constant Field Values

minutesPerHour

public static final int minutesPerHour

The number of minutes per hour is 60.

See Also:
Constant Field Values

secondsPerMinute

public static final int secondsPerMinute

The number of seconds per minute is 60.

See Also:
Constant Field Values

nanosecondsPerMillisecond

public static final int nanosecondsPerMillisecond

The number of nanoseconds per millisecond is 1000000.

See Also:
Constant Field Values

nanosecondsPerSecond

public static final long nanosecondsPerSecond

The number of nanoseconds per second is 1000000000.

See Also:
Constant Field Values

nanosecondsPerMinute

public static final long nanosecondsPerMinute

The number of nanoseconds per minute.

See Also:
Constant Field Values

nanosecondsPerHour

public static final long nanosecondsPerHour

The number of nanoseconds per hour.

See Also:
Constant Field Values

nanosecondsPerDay

public static final long nanosecondsPerDay

The number of nanoseconds per day.

See Also:
Constant Field Values

minTimeInNs

public static final long minTimeInNs

The minimum time in nanoseconds is 0.

See Also:
Constant Field Values

maxTimeInNs

public static final long maxTimeInNs

The maximum time in nanoseconds is one less than the total number of nanoseconds in a day (nanosecondsPerDay - 1).

See Also:
Constant Field Values

min

public static final TimeValue min

The minimum TimeValue = t(00:00:00.000000000)


max

public static final TimeValue max

The maximum TimeValue = t(23:59:59.999999999)

Method Detail

NormalizeTimeInNs

public static long NormalizeTimeInNs(long timeInNs)

Returns a normalized time value represented in nanoseconds.

Parameters:
timeInNs - the time in nanoseconds
Returns:
a normalized time value represented in nanoseconds

now

public static TimeValue now()

Returns a TimeValue object that represents the current time when the method is called.

Returns:
a TimeValue object that represents the current time when the method is called

fromTimeInNs

public static TimeValue fromTimeInNs(long timeInNs)

Returns a TimeValue object that represents the given timeInNS.

Parameters:
timeInNs - the number of nanoseconds elapsed since midnight
Returns:
a TimeValue object that represents the given timeInNS
Throws:
java.lang.IllegalArgumentException - if timeInNs is not between minTimeInNs and maxTimeInNs

fromCRTime

public static TimeValue fromCRTime(int CRTime)

Internal use only.


fromOleDate

public static TimeValue fromOleDate(double OleDate)

Internal use only.


getOleDate

public double getOleDate()

Internal use only.


fromHMSN

public static TimeValue fromHMSN(int hours,
                                 int minutes,
                                 int seconds,
                                 long nanoseconds)

Returns a TimeValue object that represents the given hours, minutes, seconds, and nanoseconds parameters.

Parameters:
hours - the number of hours (valid values are between 0 and 23)
minutes - the number of minutes (valid values are between 0 and 59)
seconds - the number of seconds (valid values are between 0 and 59)
nanoseconds - the number of nanoseconds (valid values are between 0 and 999999999)
Returns:
a TimeValue object that represents the given hours, minutes, seconds, and nanoseconds parameters
Throws:
java.lang.IllegalArgumentException - if any argument is outside the valid range

fromHMS

public static TimeValue fromHMS(int hours,
                                int minutes,
                                double seconds)

Returns a TimeValue object that represents the given hours, minutes and seconds parameters.

Parameters:
hours - the number of hours (valid values are between 0 and 23)
minutes - the number of minutes (valid values are between 0 and 59)
seconds - the number of seconds (valid values are between 0 and 59.999999999)
Returns:
a TimeValue object that represents the given hours, minutes and seconds parameters
Throws:
java.lang.IllegalArgumentException - if any argument is outside the valid range

fromCalendar

public static TimeValue fromCalendar(java.util.Calendar calendar)

Returns a TimeValue object that represents the time in the specified Calendar object.

Parameters:
calendar - the Calendar object to represent
Returns:
a TimeValue object that represents the time in the specified Calendar object

getTimeInNs

public long getTimeInNs()

Gets the time in nanoseconds from this TimeValue object.

Returns:
the total number of nanoseconds elapsed since midnight

getCRTime

public static int getCRTime(TimeValue time)

Internal use only.


getCRTime

public int getCRTime()

Internal use only.


getHours

public int getHours()

Gets the hours component of this TimeValue object.

Returns:
an int that represents the hours component of this TimeValue object

getMinutes

public int getMinutes()

Gets the minutes component of this TimeValue object.

Returns:
an int that represents the minutes component of this TimeValue object

getWholeSeconds

public int getWholeSeconds()

Gets the seconds component of this TimeValue object.

Returns:
an int that represents the seconds component of this TimeValue object

getSeconds

public double getSeconds()

Gets the seconds component of this TimeValue object.

Returns:
an double that represents the (fractional) seconds component of this TimeValue object

getNanoseconds

public long getNanoseconds()

Gets the nanoseconds component of this TimeValue object.

Returns:
an int that represents the nanoseconds component of this TimeValue object

getValueType

public ValueType getValueType()

Returns the ValueType of this TimeValue object.

Returns:
ValueType.time

coerceToTime

public FormulaValue coerceToTime()

Internal use only.

Overrides:
coerceToTime in class FormulaValue

coerceToDateTime

public FormulaValue coerceToDateTime()

Internal use only.

Overrides:
coerceToDateTime in class FormulaValue

equals

public boolean equals(java.lang.Object obj)

Determines whether the parameter Object is a TimeValue object with the same class and value as this object.

Parameters:
obj - the Object to compare this TimeValue object to
Returns:
true if obj has the same class and value is this TimeValue object

compareTo

public int compareTo(java.lang.Object obj,
                     java.util.Comparator stringComparator)

Internal use only.


hashCode

public int hashCode()

Returns a hash code for this TimeValue object.

Returns:
a hash code

compareTo

public int compareTo(java.lang.Object obj)

Internal use only.

Specified by:
compareTo in interface java.lang.Comparable

addNumberToTime

public TimeValue addNumberToTime(double nSeconds)

Add nSeconds seconds to the current time. If nSeconds is negative, nSeconds seconds is subtracted from the time.

Parameters:
nSeconds - the number of (fractional) seconds to add to the current time
Returns:
a normalized TimeValue object with the updated time

toString

public java.lang.String toString()

Returns a String representation of this TimeValue object. The String is of the form: "t(hh:mm:ss.nnnnnnnn)", where:
- hh is the hour of the day (00 through 23), as two decimal digits
- mm is the minute within the hour (00 through 59), as two decimal digits
- ss is the second within the minute (00 through 61, as two decimal digits
- nnnnnnnnn is the nanosecond within the second (000000000 through 999999999), as nine decimal digits

Returns:
a String representation of this TimeValue object

To1900Format

public static double To1900Format(TimeValue time)

Returns a double that represents the time in the 1900 format system (the fraction of the day completed since midnight).

Parameters:
time - a DateValue object to be represented in 1900 format system
Returns:
a double that represents the time in the 1900 format system