Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Format function
giusca78
Hi all,
Is it to possible format string, number, datetime values in the code?
I don't want use format features of data elements or dynamic text, i need to format my values in the code.
Giuseppe
Find more posts tagged with
Comments
johnw
Yes. You can use standard Java libraries to format your code.
If you put the following in an expression in your Data element, it will format it as a Year value as YYYY-MM-DD format.
var dateFormater = new java.text.SimpleDateFormat('yyyy-mm-dd');
dateFormater.format(someDateValue);
You can also use standard Java string functions as well.
John
giusca78
hi johnw,
thanks for the answer.
If I want use this approach in the onFetch function of the Dataset object, how can I use this?
I have tried to use this code in my Fetch function but I retrieve a report generation error.
I have used this sintax:
var dateFormater = new java.text.SimpleDateFormat('yyyy-mm-dd');
myVar = reportContext.getPersistentGlobalVariable("Data");
myVar += dateFormatter.format(row["field"]) + "
";
reportContext.setPersistentGlobalVariable("myValue",myVar );
Giuseppe
johnw
Let me write this up in a blog post since this is a pretty common question. I will post the link when done.
John
giusca78
thank a lot johnw