mellon Posted April 8, 2009 Share Posted April 8, 2009 I get "time" from datebase, and I want the jasper report show the time in "dd.MM.yyyy hh:mm" format, what should I do in Code: (what to do if "time" is String type, and what to do if "time" is Date type )??Post Edited by Xi Chen at 04/08/09 16:29 Link to comment Share on other sites More sharing options...
caifanmayor Posted April 8, 2009 Share Posted April 8, 2009 Remember everything in iReport are objects you should just use a SimpleDateFormat, take a look at the class description in API. First convert your String to a Date object new SimpleDateFormat("dd.MM.yyyy.HH.mm").format(new Date()) Link to comment Share on other sites More sharing options...
mellon Posted April 9, 2009 Author Share Posted April 9, 2009 caifanmayorWrote: Remember everything in iReport are objects you should just use a SimpleDateFormat, take a look at the class description in API. First convert your String to a Date object new SimpleDateFormat("dd.MM.yyyy.HH.mm").format(new Date()) Hi, I want to do the date formate inside *.jrxml file code, how to do it? Could you please give some sample code based on my code bellow? (I am quite new in Jasperreport, I do not know how to do the date format inside *.jrxml) thanks.Code:<textFieldExpression class="java.lang.String"><![CDATA[$F{time}]]></textFieldExpression> Link to comment Share on other sites More sharing options...
dman Posted April 9, 2009 Share Posted April 9, 2009 if "time" is of type String:<textFieldExpression class="java.lang.String"><![CDATA[new java.text.SimpleDateFormat("dd.MM.yyyy hh:mm").format(new java.text.SimpleDateFormat("dd.MM.yyyy hh:mm").parse($P{time}))]]></textFieldExpression>if "time" is of type Date:<textFieldExpression class="java.lang.String"><![CDATA[new java.text.SimpleDateFormat("dd.MM.yyyy hh:mm").format($P{time})]]></textFieldExpression> Link to comment Share on other sites More sharing options...
elenauscom.u Posted July 20, 2018 Share Posted July 20, 2018 Why don't work? 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