2004 IR Help Posted September 2, 2006 Share Posted September 2, 2006 By: Allen Pham - allenvpn How to format TIME from database 2004-09-01 21:32 Hi I'm trying to format a TIME type field from MySQL. From the report query, it see's TRANSACTION_TIME as a java.util.Date data type. Below is the error message I'm getting. java.sql.SQLException:?Cannot?convert?value?'00:00:00'?from?column?9(00:00:00?)?to?DATE. ????at?com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1044) ????at?com.mysql.jdbc.ResultSet.getDate(ResultSet.java:913) ????at?com.mysql.jdbc.ResultSet.getDate(ResultSet.java:927) ????at?dori.jasper.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:164) ????at?dori.jasper.engine.fill.JRBaseFiller.next(JRBaseFiller.java:723) ????at?dori.jasper.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:173) ????at?dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:554) ????at?dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:471) ????at?dori.jasper.engine.fill.JRFiller.fillReport(JRFiller.java:120) ????at?dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:222) ????at?dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:162) ????at?it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:415) ????at?java.lang.Thread.run(Unknown?Source) By: Andrew McLaughlin - pik0 RE: How to format TIME from database 2004-09-01 21:38 Change the type to java.util.Date and change the expression to something like this: new SimpleDateFormat( "HH:mm:ss" ).parse( $F{ TRANSACTION_TIME } ); That should correctly convert your string time value to a usable internal time value. Then, you can format it as you like it... Piko By: Allen Pham - allenvpn RE: How to format TIME from database 2004-09-02 08:55 Tried it and getting this error. Errors compiling .EODTransaction.jasper! dori.jasper.engine.JRException:?Errors?were?encountered?when?compiling?report?expressions?class?file: C:iReport-0.3.2EODTransaction.java:191:?cannot?resolve?symbol symbol??:?method?parse?(java.util.Date) location:?class?java.text.SimpleDateFormat ????????????????value?=?(java.util.Date)(new?java.text.SimpleDateFormat("HH:mm:ss").parse(((java.util.Date)field_TRANSACTION_TIME.getValue()))); By: Andrew McLaughlin - pik0 RE: How to format TIME from database 2004-09-02 11:00 You need to change the field type of TRANSACTION_TIME to java.util.String. Piko By: Allen Pham - allenvpn RE: How to format TIME from database 2004-09-02 11:20 Okay. I got it to work. Thank you :-)! By: Andrew McLaughlin - pik0 RE: How to format TIME from database 2004-09-02 11:52 Excellent!! iReports ROCKS!!! :) Piko Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now