com.crystaldecisions.reports.common.value
Class DateValue

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

public final class DateValue
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 nullCRDate
           A null CRDate value.
 
Method Summary
 DateValue addNumberToDate(int n)
           Adds n days to the current date.
 FormulaValue coerceToDate()
           Internal use only.
 FormulaValue coerceToDateTime()
           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 DateValue object with the same class and value as this object.
static DateValue fromCalendar(java.util.Calendar calendar)
           Returns a DateValue object that represents the date in the specified Calendar object.
static DateValue fromCRDate(int CRDate)
           Internal use only.
static DateValue fromOleDate(double OleDate)
           Internal use only.
static DateValue fromYMD(int year, int month, int day)
           Returns a DateValue object that represents the specified year, month, and day.
 int getCRDate()
           Internal use only.
static int getCRDate(DateValue date)
           Internal use only.
 RangeValue getDateTimeRangeValue()
           Gets a RangeValue object whose range covers this day.
 int getDay()
           Gets the day component of this DateValue object.
 DateTimeValue getEndOfDayDateTimeValue()
           Gets a DateTimeValue object that represents the end of this day.
 int getMonth()
           Gets the month component of this DateValue object.
 double getOleDate()
           Internal use only.
 DateTimeValue getStartOfDayDateTimeValue()
           Gets a DateTimeValue object that represents the beginning of this day.
 ValueType getValueType()
           Gets the ValueType of this DateValue object.
 int getYear()
           Gets the year component of this DateValue object.
 int hashCode()
           Returns a hash code for this DateValue object.
static boolean isValidOleDate(double OleDate)
           Internal use only.
static DateValue now()
           Returns a DateValue object that represents the current date when the method is called.
static double To1900Format(DateValue date)
           Returns a double that represents the date in the 1900 format system (the number of days since Jan 1, 1900).
 java.lang.String toString()
           Returns a String representation of this DateValue object.
 
Methods inherited from class com.crystaldecisions.reports.common.value.FormulaValue
coerce, coerceToArray, coerceToArray, coerceToBoolean, coerceToBoolean, coerceToCurrency, coerceToCurrency, coerceToDate, coerceToDateTime, coerceToNumber, coerceToNumber, coerceToRange, coerceToRange, coerceToRangeArray, coerceToRangeArray, coerceToString, coerceToString, coerceToTime, coerceToTime, getFormulaValueType, makeZeroValue
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

nullCRDate

public static final int nullCRDate

A null CRDate value.

See Also:
Constant Field Values
Method Detail

now

public static DateValue now()

Returns a DateValue object that represents the current date when the method is called.

Returns:
DateValue

fromCRDate

public static DateValue fromCRDate(int CRDate)

Internal use only.


fromYMD

public static DateValue fromYMD(int year,
                                int month,
                                int day)

Returns a DateValue object that represents the specified year, month, and day.

Parameters:
year - the complete year (for example, 2002)
month - 1-based (for example, 1 for January)
day - the day of the month
Returns:
a DateValue object that represents the specified year, month, and day
Throws:
java.lang.IllegalArgumentException - if the specified year, month, and day do not represent a valid date

fromCalendar

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

Returns a DateValue object that represents the date in the specified Calendar object.

Parameters:
calendar - the Calendar object to represent as a DateValue object
Returns:
a DateValue object that represents the date in the specified Calendar object

fromOleDate

public static DateValue fromOleDate(double OleDate)

Internal use only.


isValidOleDate

public static boolean isValidOleDate(double OleDate)

Internal use only.


getOleDate

public double getOleDate()

Internal use only.


getCRDate

public static int getCRDate(DateValue date)

Internal use only.


getCRDate

public int getCRDate()

Internal use only.


getYear

public int getYear()

Gets the year component of this DateValue object.

Returns:
an int that represents the year component of this DateValue object

getMonth

public int getMonth()

Gets the month component of this DateValue object.

Returns:
an int that represents the month component of this DateValue object

getDay

public int getDay()

Gets the day component of this DateValue object.

Returns:
an int that represents the day component of this DateValue object

getValueType

public ValueType getValueType()

Gets the ValueType of this DateValue object.

Returns:
ValueType.date

coerceToDate

public FormulaValue coerceToDate()

Internal use only.

Overrides:
coerceToDate in class FormulaValue

coerceToDateTime

public FormulaValue coerceToDateTime()

Internal use only.

Overrides:
coerceToDateTime in class FormulaValue

getStartOfDayDateTimeValue

public DateTimeValue getStartOfDayDateTimeValue()

Gets a DateTimeValue object that represents the beginning of this day.

Returns:
a DateTimeValue object that represents the beginning of this day

getEndOfDayDateTimeValue

public DateTimeValue getEndOfDayDateTimeValue()

Gets a DateTimeValue object that represents the end of this day.

Returns:
a DateTimeValue object that represents the end of this day

getDateTimeRangeValue

public RangeValue getDateTimeRangeValue()

Gets a RangeValue object whose range covers this day.

Returns:
a RangeValue object whose range covers this day

hashCode

public int hashCode()

Returns a hash code for this DateValue object.

Returns:
the hash code

equals

public boolean equals(java.lang.Object obj)

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

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

compareTo

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

Internal use only.


compareTo

public int compareTo(java.lang.Object obj)

Internal use only.

Specified by:
compareTo in interface java.lang.Comparable

addNumberToDate

public DateValue addNumberToDate(int n)

Adds n days to the current date. If n is negative, n days is subtracted from the date

Parameters:
n - the number of days to add to the current date
Returns:
a new DateValue object with the updated date

toString

public java.lang.String toString()

Returns a String representation of this DateValue object. The String is of the form: "d(yyyy-mm-dd)", where:
- yyyy is the year in four digits (for example, 2004)
- mm is the month in two digits (for example, 01 through 12)
- dd is the day of the month in two digits (for example, 01 through 31)

Returns:
a String representation of this DateValue object

To1900Format

public static double To1900Format(DateValue date)

Returns a double that represents the date in the 1900 format system (the number of days since Jan 1, 1900).

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