How to set dynamic pattern for text field

I want to show date in text field in jasper report. I've kept expression class of that text field as "java.util.Date" because while exporting that date in excel I want to retain "format cells-category as Date or Custom type" instead of General. So that user can change date format if he wants. I don't want to use "java.text.DateFormat" because of the same above given reason. But I want to pass my date format as parameter to report and use that in report.

like pattern = "$P{myDateFormat}"

myDateFormat can be anything dd-MMM-yyy, dd/MM/yy or just anything given in java

But problem is, pattern property of textField does not take expression. I saw one bug closed for jasper which had same requirement see link. But don't know why it's not working.

http://community.jaspersoft.com/ireport-designer/issues/932

http://community.jaspersoft.com/jasperreports-library/issues/4905

Also read of patternExpression but it's not present in ireport. 

Kindly tell me how to pass dynamic value to pattern.

archanwizardsqueen's picture
Joined: Oct 28 2015 - 3:10am
Last seen: 7 years 3 months ago

I think that the commnity wiki that I quote below would be helpful regarding your question:

http://community.jaspersoft.com/wiki/how-use-built-msg-function-apply-cu...

 

one more article,

http://community.jaspersoft.com/wiki/how-resource-bundlealternate-way-ge...

akonkin - 7 years 11 months ago

2 Answers:

I think that the commnity wiki that I quote below would be helpful regarding your question:

http://community.jaspersoft.com/wiki/how-use-built-msg-function-apply-cu...

 

one more article,

http://community.jaspersoft.com/wiki/how-resource-bundlealternate-way-ge...

 

akonkin's picture
102055
Joined: Mar 28 2012 - 4:29am
Last seen: 4 years 11 months ago

I found the answer from jaspersoft support:-

we can use patternExpression but it's not available in lower versions of iReport IDE so you need to compile and deploy jasper externally.

<textFieldExpression class="java.util.Date"><![CDATA[$P{d8}]]></textFieldExpression>
<patternExpression><![CDATA[$P{userDateFormat}]]></patternExpression>

 

 

archanwizardsqueen's picture
Joined: Oct 28 2015 - 3:10am
Last seen: 7 years 3 months ago
Feedback