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)
Accessing dataset input paramter inside onrender script of a control
ahmedmdm
<p>Hi,</p>
<p>I have a dataset with an input parameter "timezone" along with start time and start date. My use case is when report generates, it uses the provided timezone.</p>
<p> </p>
<p>So,When i am rendering the start time, inside onrender method i tried doing something like below</p>
<p>with no success</p>
<p> </p>
<p>importPackage(Packages.java.text.*);<br>
var dfmt = new java.text.SimpleDateFormat("MM/dd/yyyy");</p>
<p><span style="color:#ff0000;"><strong>var tz=inputParams["timeZone"] ; </strong></span></p>
<p><span style="color:#ff0000;"><strong>var tz1= params["timeZone"] ;</strong></span></p>
<p>
dfmt.setTimeZone(java.util.TimeZone.getTimeZone("America/New_York"));<br>
this.setDisplayValue( dfmt.format(this.getValue()) );</p>
<p> </p>
<p>Is there a diff way to access the dataset parameter?</p>
<p> </p>
<p>Also i am trying to format the date using the timezone hard coded as below, but i running into below error</p>
<p> </p>
<p>Caused by: org.mozilla.javascript.EvaluatorException: The choice of Java constructor format matching JavaScript argument types (null) is ambiguous; candidate constructors are:<br>
class java.lang.String format(java.lang.Object)<br>
class java.lang.String format(java.util.Date)</p>
<p> </p>
<p>Is there a better way to display date based on different timezones?</p>
<p> </p>
<p>Thanks,</p>
<p>Ahmed</p>
<p> </p>
<p>P.S : I cannot update default timezone for the report because it can have multiple timezones for various sections.</p>
<p> </p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>I have attached an example that should help you. The technique I have used is to modify the initialize method of the report to instantiate the DateFormat Java object and read the value of the report parameter. Then, I use a Text element to display a date field by using the DateFormat.format() method.</p>
<p> </p>
<p>The initialize method looks like this:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">importPackage(Packages.java.text);<br>
importPackage(Packages.java.util);<br>
dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);<br>
dateFormat.setTimeZone(TimeZone.getTimeZone(params["pTimeZone"].value));</span></p>
<p> </p>
<p>and the Text item looks like this:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;"><VALUE-OF>dateFormat.format(row["MYTIME"])</VALUE-OF></span></p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
yoovrajkhullar
<blockquote class="ipsBlockquote" data-author="pricher" data-cid="130011" data-time="1407417642">
<div>
<p>Hi,</p>
<p> </p>
<p>I have attached an example that should help you. The technique I have used is to modify the initialize method of the report to instantiate the DateFormat Java object and read the value of the report parameter. Then, I use a Text element to display a date field by using the DateFormat.format() method.</p>
<p> </p>
<p>The initialize method looks like this:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">importPackage(Packages.java.text);<br>
importPackage(Packages.java.util);<br>
dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);<br>
dateFormat.setTimeZone(TimeZone.getTimeZone(params["pTimeZone"].value));</span></p>
<p> </p>
<p>and the Text item looks like this:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;"><VALUE-OF>dateFormat.format(row["MYTIME"])</VALUE-OF></span></p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
</div>
</blockquote>
<p>Hi P Richer</p>
<p>I have been your fan for different BIRT Reports. You make it simple to understand.</p>
<p>I need urgent help for this very Report.</p>
<p>My issue for this Timezone.rptdesign i dont have to pass the TimeZone as paramter like America/New_York.</p>
<p>The timezone should be automatically coming for the End User Time Zone.</p>
<p> </p>
<p>Here is the scenario, my IHub Server is on GMT TimeZone.</p>
<p>I want a reliable way of converting GMT Time Zone into USer Time Zone.</p>
<p> </p>
<p><span style="color:#1f497d;">Specifically, it’s related to dynamic dates. For instance where report runs and there is a report parameter like “Order Date†= “Todayâ€.</span></p>
<p><span style="color:#1f497d;">All our server run in GMT time zone. So, when report runs on “3/16/2016 2:00AM GMTâ€, in “America/New_York†it’s still “3/15/2016â€.</span></p>
<p> </p>
<p>I want a reliable way of converting GMT Time Zone into USer Time Zone.</p>
<p> </p>
<p>Please help in urgently required.</p>
<p> </p>
<p>Thanks</p>
<p>Raj</p>
<p> </p>
<p> </p>
<p><span style="font-family:arial, sans-serif;font-size:small;">Hi Richer</span></p>
<div style="font-family:arial, sans-serif;font-size:small;"> </div>
<div style="font-family:arial, sans-serif;font-size:small;">In continuation to my post, basically i want the second line(User Time Zone) working not the first one as first gives me IServer GMT Time zone where Server is .</div>
<div style="font-family:arial, sans-serif;font-size:small;"> </div>
<div style="font-family:arial, sans-serif;font-size:small;">
<div>var tz = reportContext.getAppContext().get("AppRuntimeTimeZone");</div>
<div>//var tz = reportContext.getAppContext().get("UserTimeZone");</div>
<div> </div>
<div>I mean what is the name of AppContext For UserTimeZone</div>
<div> </div>
<div>Thank you so much in advance</div>
</div>