|
Business Components | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
oracle.jbo.domain.Date
This class provides a lightweight wrapper for oracle.sql.DATE, the Java representation of the DATE database type. This wrapper allows an instance of the oracle.sql.DATE to be used as an immutable domain object.
The intent of many of the methods in this class is to wrap the corresponding method in the oracle.sql class such that it returns an instance of an oracle.jbo.domain.* object.
The oracle.jbo.domain.DateDomain class is the Java representation of the underlying database type that you must use if you want to exploit the domain feature of Business Components for Java.
Date
objects consist of data (a byte array)
and a Domain type code.
Domain dates extend SQL dates by being convertable to and from
JDBC values.
... oracle.jbo.domain.Date tmpDate = null; SimpleDateFormat tmpLocalFormat = new SimpleDateFormat(); SimpleDateFormat tmpLocalFormat2 = new SimpleDateFormat(); // obtain a date element tmpDate = (oracle.jbo.domain.Date) session.getValue("DateElem"); // test that the date is not null if (tmpDate == null) { // throw an exception throw new RuntimeException("Date is invalid."); } // initialize the date format objects tmpLocalFormat.applyPattern("yyyy-MM-dd"); tmpLocalFormat2.applyPattern("dd-MM-yyyy"); // convert the date formats yyyy-MM-dd => dd-MM-yyyy tmpWhereClause = new String(tmpLocalFormat2.format(tmpLocalFormat.parse(tmpDate.toString()))); ...
Another example follows:
... Date convertedDate = new Date(); String convertedDateString; SimpleDateFormat displayDateFormat = new SimpleDateFormat ("MM'/'dd'/'yyyy"); convertedDateString = displayDateFormat.format(convertedDate);
... oracle.jbo.domain.Date dt = this.getBirth(); java.sql.Date ts = (java.sql.Date) dateValue(); // since java.sql.Date is a java.util.Date, then... Calendar c = new Calendar(dt); ...
Constructor Summary |
Date()
Creates a default Date Domain object. |
Date(byte[] value)
Internal: Applications should not invoke this method. |
Date(Date value)
Creates a Date identical to an
existing Date . |
Date(java.sql.Date value)
Creates a Date Domain object from a JDBC
Date . |
Date(DATE value)
Creates a Date Domain object from an Oracle SQL
DATE . |
Date(java.lang.Object value)
Creates a Date Domain object from a
JDBC Object . |
Date(java.lang.String value)
Creates a Date Domain object from a
Java String . |
Date(java.sql.Time value)
Creates a Date Domain object from a JDBC
Time object. |
Date(java.sql.Timestamp value)
Creates a Date Domain object from a JDBC
Timestamp object. |
Method Summary |
Type | Method |
---|---|
DATE |
addJulianDays(int julianDay,
int julianSec)
Adds the number of Julian days to a DateDomain. |
DATE |
addMonths(int months)
Adds months to a date. |
Number |
diffInMonths(Date date)
Calculates the difference between two dates in months. |
NUMBER |
diffInMonths(DATE date)
Calculates the difference between two dates in months. |
boolean |
equals(java.lang.Object other)
Tests this for equality with another object. |
static DATE |
fromJulianDays(int julianDay,
int julianSec)
Converts given Julian days and seconds to a date. |
static DATE |
fromText(java.lang.String datestr,
java.lang.String fmt,
java.lang.String lang)
Converts a formatted string to a date. |
static DATE |
getCurrentDate()
Gets current date and time. |
static CustomDatumFactory |
getCustomDatumFactory()
Internal: Applications should not invoke this method. |
java.lang.Object |
getData()
Internal: Applications should not invoke this method. |
int |
hashCode()
Computes a hash code for this . |
DATE |
lastDayOfMonth()
Returns a date intialized to the last day of the month. |
static void |
main(java.lang.String[] argv)
Internal: Applications should not invoke this method. |
DATE |
round(java.lang.String prec)
Returns a date rounded to a specified precision. |
void |
setContext(oracle.jbo.domain.DomainOwnerInterface owner,
oracle.jbo.Transaction trans,
java.lang.Object ctx)
Internal: Applications should not invoke this method. |
DATE |
setDayOfWeek(int day)
Returns a date initialized to a date advanced to the week of the day specified. |
static Date |
toDate(java.lang.String value)
Converts an Oracle Date expressed as a string to a Java Date. |
Datum |
toDatum(OracleConnection conn)
Internal: Applications should not invoke this method. |
NUMBER |
toNumber()
Converts this date to an oracle.sql.NUMBER. |
java.lang.String |
toString()
For testing purposes only: converts this to a textual
representation. |
DATE |
truncate(java.lang.String prec)
Returns a date truncated to a specified precision. |
Constructor Detail |
public Date()
Date
Domain object.
This constructor does not create a null date:
use one of the NullValue()
constructors.
public Date(byte[] value)
Creates a Date
Domain object from the given byte array.
value
- a value returned by a previous call to
getBytes()
on an SQL object compatable with
Date
.public Date(DATE value)
Date
Domain object from an Oracle SQL
DATE
.value
- a DATE
SQL object.public Date(Date value)
Date
identical to an
existing Date
.value
- a Date
Domain object.public Date(java.sql.Date value)
Date
Domain object from a JDBC
Date
.value
- a DATE
SQL object.public Date(java.sql.Time value)
Date
Domain object from a JDBC
Time
object.value
- a Time
SQL object.public Date(java.sql.Timestamp value)
Date
Domain object from a JDBC
Timestamp
object.value
- a TimeStamp
SQL object.public Date(java.lang.Object value) throws java.sql.SQLException
Date
Domain object from a
JDBC Object
.value
- an Object
that is an instance of
Date
,
Time
, Timestamp
, or
String
.java.sql.SQLException
- if the object is not of one of the recognized classes.public Date(java.lang.String value)
Date
Domain object from a
Java String
.value
- a textual representation of a Date
.Method Detail |
public static CustomDatumFactory getCustomDatumFactory()
Initializes the Date
Domain.
This method is invoked when JBO is initialized. Applications should not call this method directly.
CustomDatumFactory
for the
Date
Domain.public Datum toDatum(OracleConnection conn) throws java.sql.SQLException
Converts this Date
Domain object back into an
SQL DATE
object.
conn
- Not used.Datum
containing DATE
object.SQLException
- Never.public java.lang.Object getData()
public void setContext(oracle.jbo.domain.DomainOwnerInterface owner, oracle.jbo.Transaction trans, java.lang.Object ctx)
public static Date toDate(java.lang.String value)
public java.lang.String toString()
this
to a textual
representation.public boolean equals(java.lang.Object other)
this
for equality with another object.
The argument is converted to a Date
object, if necessary.other
- an arbitrary Object
.true
if conversion was successful and the converted
argument is identical to this
.public int hashCode()
this
.this
.public DATE addJulianDays(int julianDay, int julianSec)
Date
Domain object initalized to the DATE
values added to the Julian days.julianDay
- number of Julian days to add to Date.julianSec
- number of seconds past midnight.Date
Domain object.oracle.jbo.domain.GenericDomainException
- public DATE addMonths(int months)
Date
Domain object.public Number diffInMonths(Date date)
Date
Domain object.date
- Date to be subtracted as a DateDomain.public NUMBER diffInMonths(DATE date)
Date
Domain object.date
- Date to be subtracted, as an oracle.sql.DATE.public static DATE getCurrentDate()
Date
Domain object.public static DATE fromJulianDays(int julianDay, int julianSec)
Date
Domain object.julianDay
- Number of Julian daysjulianSec
- Number of seconds past midnightoracle.jbo.domain.GenericDomainException
- public static DATE fromText(java.lang.String datestr, java.lang.String fmt, java.lang.String lang)
Date
Domain object.
param datestr text to convertfmt
- formatlang
- the NLS language the conversion is to be performed in,
null indicates use default.oracle.jbo.domain.GenericDomainException
- public DATE lastDayOfMonth()
Date
Domain object.oracle.jbo.domain.GenericDomainException
- public DATE round(java.lang.String prec)
Date
Domain object.prec
- precision to use while roundingoracle.jbo.domain.GenericDomainException
- public DATE setDayOfWeek(int day)
Date
Domain object.day
- day of the week the date needs to be advancedoracle.jbo.domain.GenericDomainException
- public NUMBER toNumber()
Date
Domain object.oracle.jbo.domain.GenericDomainException
- public DATE truncate(java.lang.String prec)
prec
- precision to use while truncatingDate
Domain object.oracle.jbo.domain.GenericDomainException
- public static void main(java.lang.String[] argv) throws java.sql.SQLException
|
Business Components | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |