Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Allways return NULL when using getTimestamp() ?

Re: Allways return NULL when using getTimestamp() ?

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Sat, 18 Sep 1999 22:47:25 GMT
Message-ID: <37E41708.349A36F3@rationalconcepts.com>


Hi Eric,

   Could be many things...
   You don't say what version of java you are developing in...    You don't say what driver you are using...     The driver could have a bug...

   Like I said, could be any number of things...    So, instead of grabbing it as a timestamp,    try the following:

   SimpleDateFormat formatterDB = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");

   SimpletDateFormat myTimeStamp = new SimpleDateFormat("dd-MM-yyyy kk:mm:ss");

   String myDateTime;

   try {

       myDateTime = resultSet.getDate("yourDateColumn").toString();
       if (myDateTime != null && !myDateTime.equals("")) {
            Date transDate = formatterDB.parse(myDateTime);
            System.out.println("The returned date/time is " +
myTimeStamp.format(transDate));
      }
     else {
            System.out.println("The date returned was either null or
blank.");

    }
  catch (Exception e) {

        System.out.println(e.getMessage());
        e.printStackTrace();

 }

regards,
Cindy

Eric wrote:

> Hello,
>
> In Oracle, I use TO_DATE('18-09-1999 10:28:56', 'DD-MM-YYYY HH24:MI:SS')
> to insert a date to the database.
>
> In Java, I use resultSet.getTimestamp("somefield") to get back the
> value.
> But it always return NULL. Would you please to tell me why ?
>
> Best regards,
> Eric
Received on Sat Sep 18 1999 - 17:47:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US