473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Can you help me with JDBC getDate() error?

Hi,

I am observing a strange error with the time portion of the java.sql.Date()
when using resultSet.getDate() - it always seems to show 12:00:00.

The following code prints 2004-10-27 11:00:00.0

String dtStr = resultset.getString("PROMISEDATE");
System.out.println(dtStr);

The following code prints 2004-10-27 12:00:00
java.util.Date dt = resultset.getDate("PROMISEDATE");
System.out.println(new SimpleDateFormat("yyyy-MM-dd
hh:mm:ss").format(dt));

Any clue why the getDate screws up the time? Any remedies you may suggest?

Many thanks
SB

Jul 19 '05 #1
2 10468


Spare Brain wrote:
Hi,

I am observing a strange error with the time portion of the java.sql.Date()
when using resultSet.getDate() - it always seems to show 12:00:00.

The following code prints 2004-10-27 11:00:00.0

String dtStr = resultset.getString("PROMISEDATE");
System.out.println(dtStr);

The following code prints 2004-10-27 12:00:00
java.util.Date dt = resultset.getDate("PROMISEDATE");
System.out.println(new SimpleDateFormat("yyyy-MM-dd
hh:mm:ss").format(dt));

Any clue why the getDate screws up the time? Any remedies you may suggest?
Yes, because it's a Date (date only). Try getTimestamp().
Joe Weinstein at BEA


Many thanks
SB


Jul 19 '05 #2
"Joe Weinstein" <jo*******@bea.com> wrote in message
news:42**************@bea.com...


Spare Brain wrote:
Hi,

I am observing a strange error with the time portion of the java.sql.Date() when using resultSet.getDate() - it always seems to show 12:00:00.

The following code prints 2004-10-27 11:00:00.0

String dtStr = resultset.getString("PROMISEDATE");
System.out.println(dtStr);

The following code prints 2004-10-27 12:00:00
java.util.Date dt = resultset.getDate("PROMISEDATE");
System.out.println(new SimpleDateFormat("yyyy-MM-dd
hh:mm:ss").format(dt));

Any clue why the getDate screws up the time? Any remedies you may
suggest?
Yes, because it's a Date (date only). Try getTimestamp().
Joe Weinstein at BEA


Many thanks
SB


That worked!!! Thanks Joe.
SB
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: kaiwing18 | last post by:
Hi , I have a problem relate to java and database. Could anyone answer me ?Please see the following code. import java.sql.*; public class Result { public static void main(String args) {
1
by: sid_mulpuru | last post by:
I am trying to read data from a DB2 Blob Data type Field (using wsad 5.1.0) using getBlob() which when executed gives an SQL Exception 2005-01-07 15:48:40,506 ERROR - Error in...
2
by: subman | last post by:
We currently have S.P.'s that are already coded with sql transactions. Is it possible to have a EXE that has an ADO transaction call an S.P. that has a transaction. No matter how hard I try I cant...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
1
by: kommaraju | last post by:
iam a starter to db2 & jdbc.i have a servlet program which connects to ibm db2 using jdbc.when i run this using apache tomcat 4.1.34 , it is showing a error message of HTTP STATUS 500 my jdbc...
2
by: Mangler | last post by:
I created a query in SQL that works fine but when i put it in the asp code ( with dreamweaver ) i am getting an error when viewing the page: expected end of statment... ...
0
by: stanlew | last post by:
Happy New Year everyone! I'm new to both T-SQL and this forum. I'm currently doing an internship and my first task was to create a small program which will send an email detailing the sales of the...
1
by: wnaveenkumar | last post by:
package com.trewport.orderprocess.action; import java.io.*; import java.sql.*; import java.util.*; import java.util.Date; import java.lang.Object; import javax.servlet.*; import...
2
by: Spare Brain | last post by:
Hi, I am observing a strange error with the time portion of the java.sql.Date() when using resultSet.getDate() - it always seems to show 12:00:00. The following code prints 2004-10-27...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.