summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connectivity/source/drivers/jdbc/Date.cxx125
-rw-r--r--connectivity/source/drivers/jdbc/Timestamp.cxx65
-rw-r--r--connectivity/source/inc/java/sql/Timestamp.hxx25
-rw-r--r--connectivity/source/inc/java/util/Date.hxx13
4 files changed, 69 insertions, 159 deletions
diff --git a/connectivity/source/drivers/jdbc/Date.cxx b/connectivity/source/drivers/jdbc/Date.cxx
index 1e19265a88fc..64f8ee7b44f7 100644
--- a/connectivity/source/drivers/jdbc/Date.cxx
+++ b/connectivity/source/drivers/jdbc/Date.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Date.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: oj $ $Date: 2001-05-31 08:29:15 $
+ * last change: $Author: oj $ $Date: 2001-10-18 09:24:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,25 +76,6 @@ using namespace connectivity;
jclass java_util_Date::theClass = 0;
-java_util_Date::java_util_Date( const ::com::sun::star::util::Date& _rOut ) //: java_lang_Object( NULL, (jobject)NULL ){
-{
- SDBThreadAttach t;
- if( !t.pEnv )
- return;
- jvalue args[1];
- // Parameter konvertieren
- args[0].j = ::dbtools::DBTypeConversion::toINT32(_rOut);
- // Java-Call fuer den Konstruktor absetzen
- // temporaere Variable initialisieren
- char * cSignature = "(J)V";
- jobject tempObj;
- jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
- tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args );
- saveRef( t.pEnv, tempObj );
- t.pEnv->DeleteLocalRef( tempObj );
- // und aufraeumen
-}
-
java_util_Date::~java_util_Date()
{}
@@ -119,106 +100,6 @@ void java_util_Date::saveClassRef( jclass pClass )
// der uebergebe Klassen-Handle ist schon global, daher einfach speichern
theClass = pClass;
}
+// -----------------------------------------------------------------------------
-sal_Int32 java_util_Date::getMinutes()
-{
- jint out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- char * cSignature = "()I";
- char * cMethodName = "getMinutes";
- // Java-Call absetzen
- jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
-}
-
-sal_Int32 java_util_Date::getMonth()
-{
- jint out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- char * cSignature = "()I";
- char * cMethodName = "getMonth";
- // Java-Call absetzen
- jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
-}
-
-sal_Int32 java_util_Date::getSeconds()
-{
- jint out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- char * cSignature = "()I";
- char * cMethodName = "getSeconds";
- // Java-Call absetzen
- jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
-}
-
-sal_Int32 java_util_Date::getYear()
-{
- jint out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- char * cSignature = "()I";
- char * cMethodName = "getYear";
- // Java-Call absetzen
- jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
-}
-
-sal_Int32 java_util_Date::getDate()
-{
- jint out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- char * cSignature = "()I";
- char * cMethodName = "getDate";
- // Java-Call absetzen
- jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
-}
-
-sal_Int32 java_util_Date::getHours()
-{
- jint out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- char * cSignature = "()I";
- char * cMethodName = "getHours";
- // Java-Call absetzen
- jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
-}
diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx
index bec43db3feb2..c58d11130b3f 100644
--- a/connectivity/source/drivers/jdbc/Timestamp.cxx
+++ b/connectivity/source/drivers/jdbc/Timestamp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Timestamp.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: oj $ $Date: 2001-05-31 08:29:15 $
+ * last change: $Author: oj $ $Date: 2001-10-18 09:24:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,8 +77,29 @@ using namespace connectivity;
//**************************************************************
//************ Class: java.sql.Date
//**************************************************************
-
+const double fMilliSecondsPerDay = 86400000.0;
jclass java_sql_Date::theClass = 0;
+java_sql_Date::java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java_util_Date( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ jvalue args[1];
+ // Parameter konvertieren
+ double nVal = ::dbtools::DBTypeConversion::toDouble(_rOut,::com::sun::star::util::Date(1,1,1970));
+ nVal *= fMilliSecondsPerDay;
+
+ args[0].j = (jlong)nVal;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ char * cSignature = "(J)V";
+ jobject tempObj;
+ jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ tempObj = t.pEnv->NewObject( getMyClass(), mID, args[0].j );
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ // und aufraeumen
+}
java_sql_Date::~java_sql_Date()
{}
@@ -96,6 +117,7 @@ jclass java_sql_Date::getMyClass()
}
return theClass;
}
+// -----------------------------------------------------------------------------
void java_sql_Date::saveClassRef( jclass pClass )
{
@@ -104,6 +126,11 @@ void java_sql_Date::saveClassRef( jclass pClass )
// der uebergebe Klassen-Handle ist schon global, daher einfach speichern
theClass = pClass;
}
+// -----------------------------------------------------------------------------
+java_sql_Date::operator ::com::sun::star::util::Date()
+{
+ return ::dbtools::DBTypeConversion::toDate(toString());
+}
//**************************************************************
//************ Class: java.sql.Time
@@ -143,18 +170,25 @@ java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_
return;
jvalue args[1];
// Parameter konvertieren
- args[0].j = ::dbtools::DBTypeConversion::toINT32(_rOut);
+ double nVal = ::dbtools::DBTypeConversion::getMsFromTime(_rOut);
+ // nVal = nVal * 8640000;
+
+ args[0].j = (jlong)nVal;
// Java-Call fuer den Konstruktor absetzen
// temporaere Variable initialisieren
char * cSignature = "(J)V";
jobject tempObj;
jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
- tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args );
+ tempObj = t.pEnv->NewObject( getMyClass(), mID, args[0].j );
saveRef( t.pEnv, tempObj );
t.pEnv->DeleteLocalRef( tempObj );
// und aufraeumen
}
-
+// -----------------------------------------------------------------------------
+java_sql_Time::operator ::com::sun::star::util::Time()
+{
+ return ::dbtools::DBTypeConversion::toTime(toString());
+}
//**************************************************************
//************ Class: java.sql.Timestamp
//**************************************************************
@@ -193,14 +227,20 @@ java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _
if( !t.pEnv )
return;
jvalue args[1];
- // Parameter konvertieren
- args[0].j = (jlong)::dbtools::DBTypeConversion::toINT64(_rOut);
+ // Parameter konvertieren
+ ::com::sun::star::util::Date aDate(_rOut.Day,_rOut.Month,_rOut.Year);
+ double nVal = ::dbtools::DBTypeConversion::toDouble(aDate,::com::sun::star::util::Date(1,1,1970));
+ nVal *= fMilliSecondsPerDay;
+ ::com::sun::star::util::Time aTime(_rOut.HundredthSeconds,_rOut.Seconds,_rOut.Minutes,_rOut.Hours);
+ nVal += ::dbtools::DBTypeConversion::getMsFromTime(aTime);
+
+ args[0].j = (jlong)nVal;
// Java-Call fuer den Konstruktor absetzen
// temporaere Variable initialisieren
char * cSignature = "(J)V";
jobject tempObj;
jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
- tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args );
+ tempObj = t.pEnv->NewObject( getMyClass(), mID, args[0].j );
saveRef( t.pEnv, tempObj );
t.pEnv->DeleteLocalRef( tempObj );
// und aufraeumen
@@ -242,4 +282,11 @@ void java_sql_Timestamp::setNanos( sal_Int32 _par0 )
} //mID
} //t.pEnv
}
+// -----------------------------------------------------------------------------
+java_sql_Timestamp::operator ::com::sun::star::util::DateTime()
+{
+ return ::dbtools::DBTypeConversion::toDateTime(toString());
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx
index 7331632590c8..67e18ec62c07 100644
--- a/connectivity/source/inc/java/sql/Timestamp.hxx
+++ b/connectivity/source/inc/java/sql/Timestamp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Timestamp.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: oj $ $Date: 2001-05-23 09:10:28 $
+ * last change: $Author: oj $ $Date: 2001-10-18 09:24:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -89,12 +89,10 @@ namespace connectivity
static jclass getMyClass();
virtual ~java_sql_Date();
// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
- java_sql_Date( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){}
- java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java_util_Date(_rOut) {}
- operator ::com::sun::star::util::Date()
- {
- return ::com::sun::star::util::Date((sal_uInt16)getYear(),(sal_uInt16)getMonth(),(sal_uInt16)getDate());
- }
+ java_sql_Date( JNIEnv * pEnv, jobject myObj ) : java_util_Date(pEnv,myObj){}
+ java_sql_Date( const ::com::sun::star::util::Date& _rOut );
+
+ operator ::com::sun::star::util::Date();
};
@@ -115,10 +113,7 @@ namespace connectivity
// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
java_sql_Time( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){}
java_sql_Time( const ::com::sun::star::util::Time& _rOut );
- operator ::com::sun::star::util::Time()
- {
- return ::com::sun::star::util::Time(0,(sal_uInt16)getSeconds(),(sal_uInt16)getMinutes(),(sal_uInt16)getHours());
- }
+ operator ::com::sun::star::util::Time();
};
//**************************************************************
@@ -137,11 +132,7 @@ namespace connectivity
// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
java_sql_Timestamp( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){}
java_sql_Timestamp( const ::com::sun::star::util::DateTime& _rOut);
- operator ::com::sun::star::util::DateTime()
- {
- return ::com::sun::star::util::DateTime((sal_uInt16)getYear(),(sal_uInt16)getMonth(),(sal_uInt16)getDate(),
- (sal_uInt16)getHours(),(sal_uInt16)getMinutes(),(sal_uInt16)getSeconds(),(sal_uInt16)getNanos());
- }
+ operator ::com::sun::star::util::DateTime();
sal_Int32 getNanos();
void setNanos(sal_Int32 n);
diff --git a/connectivity/source/inc/java/util/Date.hxx b/connectivity/source/inc/java/util/Date.hxx
index 121cce620d7c..edb3c1389b30 100644
--- a/connectivity/source/inc/java/util/Date.hxx
+++ b/connectivity/source/inc/java/util/Date.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Date.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $
+ * last change: $Author: oj $ $Date: 2001-10-18 09:24:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -88,15 +88,6 @@ namespace connectivity
virtual ~java_util_Date();
// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
java_util_Date( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
- java_util_Date( const ::com::sun::star::util::Date& _rOut );
-
- sal_Int32 getMonth();
- sal_Int32 getYear();
- sal_Int32 getDate();
-
- sal_Int32 getMinutes();
- sal_Int32 getSeconds();
- sal_Int32 getHours();
};
}
#endif // _CONNECTIVITY_JAVA_UTIL_DATE_HXX_