aspose file tools*
The moose likes Java in General and the fly likes problem with Date and timestamp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem with Date and timestamp" Watch "problem with Date and timestamp" New topic
Author

problem with Date and timestamp

Ashu Patel
Greenhorn

Joined: Sep 15, 2003
Posts: 10
Select to_char(tran.CRTN_DT, 'mm/dd/yyyy') outboundMsg,
ResultSet rs = pstmt.executeQuery();
while (rs.next()){
TranInfo vo = new TranInfo();
dateFormatter = DateFormat.getDateInstance();
String dateOut = dateFormatter.format((Timestamp)getTimestamp"outboundMsg"));
vo.setDateOut(dateOut);
);
vo.setCrtnDate((Timestamp) rs.getTimestamp("outboundMsg"));
this throws error stating
[java.sql.SQLException: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffffat java.sql.Timestamp.valueOf(Timestamp.java:133)
at oracle.jdbc.driver.OracleStatement.getTimestampValue(OracleStatement.
java:3860)
at oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResultSetIm
--------
please help out..what to do dont know
Sadanand Murthy
Ranch Hand

Joined: Nov 26, 2003
Posts: 382
Originally posted by Ashu Patel:
Select to_char(tran.CRTN_DT, 'mm/dd/yyyy') outboundMsg,
ResultSet rs = pstmt.executeQuery();
while (rs.next()){
TranInfo vo = new TranInfo();
dateFormatter = DateFormat.getDateInstance();
String dateOut = dateFormatter.format((Timestamp)getTimestamp"outboundMsg"));
vo.setDateOut(dateOut);
);
vo.setCrtnDate((Timestamp) rs.getTimestamp("outboundMsg"));
this throws error stating
[java.sql.SQLException: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffffat java.sql.Timestamp.valueOf(Timestamp.java:133)
at oracle.jdbc.driver.OracleStatement.getTimestampValue(OracleStatement.
java:3860)
at oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResultSetIm
--------
please help out..what to do dont know

It is telling you what the problem is. The rs.getTimestamp() method (which you are using to get outboundMsg requires the outboundMsg value to be in yyyy-mm-dd hh:mm:ss format. In your select statement you have already converted the crtn_dt to char in the format of mm/dd/yyyy. So outboundMsg that you get as a result of executing the query is String and not a Timestamp & is of the form mm/dd/yyyy. Use rs.getString("outboundMsg").
[ February 05, 2004: Message edited by: Sadanand Murthy ]

Ever Existing, Ever Conscious, Ever-new Bliss
Ashu Patel
Greenhorn

Joined: Sep 15, 2003
Posts: 10
Thanks Murthy..
It helped
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with Date and timestamp
 
Similar Threads
Comparing 2 Dates
Time stamp format
Bug in java.util.Date.toString():?
DB2 Date format to Oracle Date format?
How to convert Timestampformat to another format