javascript: toLocaleDateString and BIRT datetime functions [message #500154] |
Wed, 25 November 2009 03:39  |
Eclipse User |
|
|
|
Hi,
In my dynamic text field I have a script:
BirtDateTime.addDay(new Date(),-1).toLocaleDateString();
which doesn't work because of an error:
TypeError: Cannot find function toLocaleDateString in object Tue Nov 24
09:36:01 CET 2009. (<inline>#1)
It seems like addDay method doesn't really return javascript DateTime
object. Do you know how to solve this problem, or maybe have another
easy way to show yesterday's date in my locale?
Thanks,
Rafal
|
|
|
Re: javascript: toLocaleDateString and BIRT datetime functions [message #500339 is a reply to message #500154] |
Wed, 25 November 2009 11:56   |
Eclipse User |
|
|
|
Rafal,
This function returns a java.util.Date not a js date.
If you use a text element or data element all you have to enter is:
Data
BirtDateTime.addDay(new Date(),-1);
text
<VALUE-OF>BirtDateTime.addDay(new Date(),-1);</VALUE-OF>
In both cases the date is automatically formated for the current locale
If you have to use a dynamic text element you could format like:
var dt =BirtDateTime.addDay(new Date(),-1);
importPackage( Packages.java.text );
var sdf = new SimpleDateFormat("MMM d, yyyy HH:mm aaa");
var mydtf1 = sdf.format(dt );
mydtf1;
Jason
Rafal Wojtowicz wrote:
> Hi,
> In my dynamic text field I have a script:
>
> BirtDateTime.addDay(new Date(),-1).toLocaleDateString();
>
> which doesn't work because of an error:
>
> TypeError: Cannot find function toLocaleDateString in object Tue Nov 24
> 09:36:01 CET 2009. (<inline>#1)
>
> It seems like addDay method doesn't really return javascript DateTime
> object. Do you know how to solve this problem, or maybe have another
> easy way to show yesterday's date in my locale?
>
> Thanks,
> Rafal
|
|
|
Re: javascript: toLocaleDateString and BIRT datetime functions [message #529454 is a reply to message #500339] |
Sun, 25 April 2010 15:09   |
Eclipse User |
|
|
|
Hi Jason,
I relation to this thread, I am wondering if you've seen or have an idea why I might be experiencing some strange AddDay() behavior? I have a simple Data binding in a report which looks something like:
if(params["RunDate"].value==null){BirtDateTime.addDay(new Date(),-90)}else{BirtDateTime.addDay(params["RunDate"].value,-90)};
If I use any day within the first week of April of any year, as my selected parameter value, the result will return a full year earlier. I'm not sure if this is something that was already addressed in a patch, but I don't see this on every version of BIRT. Sadly, it is only experienced within my clients BIRT deployments. Not my own.
Ideas?
Thanks,
Ralph G.
|
|
|
Re: javascript: toLocaleDateString and BIRT datetime functions [message #529635 is a reply to message #529454] |
Mon, 26 April 2010 11:15   |
Eclipse User |
|
|
|
Ralph,
I have not seen this. What version are your clients running?
Jason
On 4/25/2010 3:09 PM, Ralph Gleason wrote:
> Hi Jason,
> I relation to this thread, I am wondering if you've seen or have an idea
> why I might be experiencing some strange AddDay() behavior? I have a
> simple Data binding in a report which looks something like:
> if(params["RunDate"].value==null){BirtDateTime.addDay(new
> Date(),-90)}else{BirtDateTime.addDay(params["RunDate"].value,-90)};
>
> If I use any day within the first week of April of any year, as my
> selected parameter value, the result will return a full year earlier.
> I'm not sure if this is something that was already addressed in a patch,
> but I don't see this on every version of BIRT. Sadly, it is only
> experienced within my clients BIRT deployments. Not my own.
> Ideas?
> Thanks,
> Ralph G.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04132 seconds