Re: [INTERFACES] Re: ResultSet.getDate

From: Peter Garner <peter_garner(at)yahoo(dot)com>
To: Peter T Mount <peter(at)retep(dot)org(dot)uk>, "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Re: ResultSet.getDate
Date: 1999-02-01 22:16:11
Message-ID: 19990201221611.27552.rocketmail@send205.yahoomail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi All! :-)

Here is an even better one for you! ;-) It seems that
Java, not JDBC is chopping the time portion in doing
the conversion from a java.util.Date to a java.sql.Date
(ResultSet.getDate converts them) Try the following,
please :

import java.sql.* ;
import java.text.* ;
import java.util.* ;

class DateTest
{
// Public Methods
public static void main ( String strgarrArgs [] )
{
try
{
SimpleDateFormat sdf = new SimpleDateFormat ( "dd MMM yyyy
HH:mm:ss" ) ;
java.util.Date date = new java.util.Date ( "01 Feb 1999
16:08:00" ) ;
System.out.println ( "\nDate is:\t" + sdf.format ( date ) ) ;
java.sql.Date sqldate = new java.sql.Date ( date.getTime ()
) ;
System.out.println ( "SQL Date is:\t" + sdf.format ( sqldate )
+ "\n" ) ;

} /* endtry */
catch ( Exception e )
{
System.out.println ( "\nCaught an Exception of type " +
e.getClass ().getName () ) ;
System.out.println ( e.getMessage () ) ;

} /* endcatch */

} /* static void main ( String strgarrArgs [] ) */

} /* class DateTest */

On my machine at least the output is :

Date is: 01 Feb 1999 16:08:00
SQL Date is: 01 Feb 1999 00:00:00

Looks like a definite bug in the JVM or just in the
Blackdown Linux v1.17 JVM! ;-) Thanks again!

==
Peace,
Peter

We are Microsoft of Borg, you will be assimilated!!!
Resistance is fut... ***BZZZRT*** THUD!!!
[General Protection Fault in MSBorg32.DLL]
Please contact the vendor for more information
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Harvey 1999-02-01 23:13:43 LinuxODBC
Previous Message Byron Nikolaidis 1999-02-01 22:06:42 Re: [INTERFACES] ODBC Locking troubles