Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to make date format applicable across report ?
bholenath
Hello,
I've a requirement wherein a report parameter will decide the date format to be displayed in report (DD/MM/YYYY , YYYY/MM/DD, etc)
This change has to be applied across the report -- whereever there is a date value.
I have to apply the selected date format at the run-time throughout the report (preferrably, using the JAVA API and not the scripting).
Is there a way that it can be achieved by using the BIRT JAVA API ?
Any inputs on the same will be really helpful.
Thanks in advance,
Cheers,
Amit
Find more posts tagged with
Comments
bholenath
I found a way out of the same and hence thought to update the post with the solution. Since I wanted the JAVA API solution instead of scripting, I wrote a java utility method that will take care of the date format across the report elements -- whereever the date data-item is found.
public void changeDateFormat(String dateFormatPattern) throws Exception{
if(reportDesignHandle != null){
FormatValue formatValue = new DateFormatValue();
formatValue.setCategory(DesignChoiceConstants.DATE_FORMAT_TYPE_CUSTOM);
formatValue.setPattern(dateFormatPattern);
SlotHandle slotHandle = reportDesignHandle.getBody();
for (Iterator iterator = slotHandle.iterator(); iterator.hasNext();) {
DesignElementHandle elementHandle = (DesignElementHandle) iterator.next();
PropertyHandle propHandle = elementHandle.getPropertyHandle("dateTimeFormat");
if(propHandle != null){
propHandle.setValue(formatValue);
}
}
}
}
If there is anyother way of accomplishing the same, do let me know.
Cheers,
Amit