yyhor Posted September 27, 2008 Share Posted September 27, 2008 Hi,I have changed the pattern as 'dd/MM/yyy' under text field's properties but the date can't display.may i know is it because of the text field expression class?the date is fetched from db and class type=integer. Thanks & Regards,yy Link to comment Share on other sites More sharing options...
svenn Posted September 29, 2008 Share Posted September 29, 2008 Probably because you're storing it as a Integer and jasper can not translate it to a date. You could try converting it to a String the using one of the Java date formating methods. Link to comment Share on other sites More sharing options...
yyhor Posted September 30, 2008 Author Share Posted September 30, 2008 Hi,The following is the jrxml code of the date field. Although i have converted it to String, but it still display the format "yyyymmdd" (this is the format which is stored in db).<textField isStretchWithOverflow="false" pattern="dd-MMM-yyyy" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="436" y="103" width="75" height="12" key="textField"/> <box></box> <textElement> <font fontName="Courier New" pdfFontName="Courier" isPdfEmbedded ="false"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{BILL_DT}]]></textFieldExpression> </textField>Thanks & Regards,yy Link to comment Share on other sites More sharing options...
svenn Posted September 30, 2008 Share Posted September 30, 2008 In this case all you have done is put an Integer value in a field defined as a String. What you should try is using the Java method to convert your value to a String then use a date formatternew SimpleDateFormat('dd-MMM-yyyy").parse( $F{BILL_DT } .toString());Set the class to java.util.Date. Link to comment Share on other sites More sharing options...
yyhor Posted October 15, 2008 Author Share Posted October 15, 2008 Hi,Many thanks for your reply.I have tried to create a variable and class type as java.util.Date, which is :<variable name="BILL-DT" class="java.util.Date" resetType="Report" calculation="Nothing"> <variableExpression><![CDATA[new SimpleDateFormat("dd MMM yyyy").parse($F{BILL_DT})]]></variableExpression> </variable> but i'm having the errors as below:-Error filling print... Error evaluating expression : Source text : new SimpleDateFormat("dd MMM yyyy").parse($F{BILL_DT}) net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : new SimpleDateFormat("dd MMM yyyy").parse($F{BILL_DT}) at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:257) at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:528) at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:173) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:753) at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1422) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:111) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:879) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:782) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:947) at java.lang.Thread.run(Unknown Source)Caused by: java.text.ParseException: Unparseable date: "20080114" at java.text.DateFormat.parse(Unknown Source) at R1_1224056800132_539306.evaluateEstimated(R1_1224056800132_539306:812) at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:246) ... 12 more Print was not filled. Try using an EmptyDataSource... any ideas ? Thanks & Regards,yy Link to comment Share on other sites More sharing options...
yyhor Posted October 15, 2008 Author Share Posted October 15, 2008 btw, the data type for field $F{BILL_DT} is :-<field name="BILL_DT" class="java.lang.String"/> Thanks & Regards,yy Link to comment Share on other sites More sharing options...
drlaz Posted October 15, 2008 Share Posted October 15, 2008 The standard Java date parser doesn't recognize the yyyymmdd format.You can try something like<CODE>new java.util.Date(-1900+d/10000, -1+(d%10000)/100 ,d%100); </CODE>That's a deprecated constructor but you can check the Java docs for a replacement.No offense, but I would suggest database redesign. Having the date stored as an integer in this format means you can't do date arithmetic (i.e., subtract two dates). Link to comment Share on other sites More sharing options...
mennei Posted October 26, 2011 Share Posted October 26, 2011 Hi to all!I try to implement table subreport. When I generate the table I get org.apache.commons.beanutils.ConversionException: Unparseable date: "1997/08/25"My pattern is "yyyy, MMM dd" and the class of the field is java.util.Date. This is the xmldatasource semple in jasper report package.What I missing?Please Help...Mennei. Post Edited by mennei at 10/26/2011 09:43 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