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: |
<textFieldExpression class="java.lang.String"><![CDATA[$F{time}]]></textFieldExpression> |
(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
4 Answers:
caifanmayor
Wrote:
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></td></tr></tbody></table> |
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>