Jump to content
We've recently updated our Privacy Statement, available here ×

How to format date to dd.MM.yyyy hh:mm


mellon

Recommended Posts

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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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>
Link to comment
Share on other sites

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

  • 9 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...