Re: [INTERFACES] Re: ResultSet.getDate

Поиск
Список
Период
Сортировка
От Peter Garner
Тема Re: [INTERFACES] Re: ResultSet.getDate
Дата
Msg-id 19990201221611.27552.rocketmail@send205.yahoomail.com
обсуждение исходный текст
Список 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


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Peter T Mount
Дата:
Сообщение: Re: [INTERFACES] Re: ResultSet.getDate
Следующее
От: Byron Nikolaidis
Дата:
Сообщение: Re: [INTERFACES] ODBC Locking troubles