Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Allways return NULL when using getTimestamp() ?
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 orblank.");
}
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
![]() |
![]() |