The Date class provides an Oracle-native date type that holds both date and time values, just like the Oracle DATE type. You may use a Format object to specify the format upon construction or output of an object, but this does not affect its value. This is analogous to the use of the TO_DATE and TO_CHAR functions in Oracle. In fact, the same format strings are used.
Figure 2-4. class Date
namespace Oracle
{
class Date: public Nullable
{
public:
// constructors/destructor
Date();
Date(const string&);
Date(const string&, const string&);
Date(const Date&);
virtual ~Date();
// implementors
Date& assign(const string&, const string&);
// accessors
virtual string str() const;
virtual string str(const string&) const;
virtual string str(const string&, const string&) const;
virtual string sql_str() const;
virtual long lng() const;
virtual long lng(const long) const;
virtual double dbl() const;
virtual double dbl(const double) const;
virtual int sqlt() const;
virtual int maxsize() const;
Date last_day() const;
Date next_day(const string&) const;
// operators
Date& operator=(const Date&);
Date& operator=(const char*);
Date& operator=(const string&);
Date& operator+=(const Days&);
Date& operator+=(const Months&);
Date& operator-=(const Days&);
Date& operator-=(const Months&);
int operator-(const Date&);
bool operator==(const Date&);
bool operator!=(const Date&);
bool operator<(const Date&);
bool operator<=(const Date&);
bool operator>(const Date&);
bool operator>=(const Date&);
// static functions
static Date sysdate();
protected:
// implementors
virtual void* data() const;
};
ostream& operator<<(ostream&, const Date&);
}
Oracle::Number operator+(const Oracle::Date&, const Oracle::Days&);
Oracle::Number operator+(const Oracle::Date&, const Oracle::Months&);
Oracle::Number operator-(const Oracle::Date&, const Oracle::Days&);
Oracle::Number operator-(const Oracle::Date&, const Oracle::Months&);Date(void);
Date(const char* initial_value);
Date(const char* initial_value, const Format& format);
Date(const string& initial_value);
Date(const string& initial_value, const Format& format);
Date(const Date& initial_value);
Date(const Nullable& initial_value);
A Date object may be initialized by a character string, another Date, or as a Nullable. If format is specified, it is used as the conversion format; if not, the default format is used ("YYYY/MM/DD HH24:MI:SS"). An Error is thrown if the conversion fails.
Date& operator=(const Nullable& new_value);
Date& operator=(const Date& new_value);
Date& operator=(const char* new_value);
Date& operator=(const string& new_value);
A Date object may be assigned a character string, another Date, or a Nullable. For character strings, the default conversion format is used ("YYYY/MM/DD HH24:MI:SS"). An Error is thrown if the conversion fails.