• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with Date and timestamp

 
Ashu Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 382
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ashu Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Murthy..
It helped
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic