• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

problem with Date and timestamp

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Murthy..
It helped
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic