Jump to content
Changes to the Jaspersoft community edition download ×

timezone conversion


sd5008

Recommended Posts

 i have a Field in my report of type 'java.util.Timestamp'. I need to display the date in the respective timezone of the user.

i am passing REPORT_TIME_ZONE as parameter from my controller as

 

LoggedUser user = (User)request.getSession().getAttribute("loggeduser");
           
            usertimezone    = user.getTimezone();

Map model=new HashMap();

model.put("REPORT_TIME_ZONE",usertimezone);

 

in my report that is the jrxml file i use

<parameter name="DateFormatter" class="java.text.DateFormat" isForPrompting="false">

    <defaultValueExpression>$P{REPORT_FORMAT_FACTORY}.createDateFormat("MMM dd, yyyy HH:mm", null, $P{REPORT_TIME_ZONE})</defaultValueExpression>

</parameter>


and in my testfield expression i use

<textFieldExpression>$P{DateFormatter}.format($F{WORK_PLAN_CREATED_TS})</textFieldExpression>

 

my end result is that i am not able to convert the date into respective timezone. please do the needfull

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

when i try to print the REPORT_TIME_ZONE in the report

using

<textFieldExpression  ><![CDATA[$P{REPORT_TIME_ZONE}.getDisplayName(true,TimeZone.SHORT)]]></textFieldExpression>

 i get to display the time zone as GMT though the timezone which i pass is IST from the spring controller

 

why is this happenening can any one tell

Link to comment
Share on other sites

sd5008

Wrote:

 i have a Field in my report of type 'java.util.Timestamp'. I need to display the date in the respective timezone of the user.

i am passing REPORT_TIME_ZONE as parameter from my controller as

 

LoggedUser user = (User)request.getSession().getAttribute("loggeduser");
           
            usertimezone    = user.getTimezone();

Map model=new HashMap();

model.put("REPORT_TIME_ZONE",usertimezone);

 

in my report that is the jrxml file i use

<parameter name="DateFormatter" class="java.text.DateFormat" isForPrompting="false">

    <defaultValueExpression>$P{REPORT_FORMAT_FACTORY}.createDateFormat("MMM dd, yyyy HH:mm", null, $P{REPORT_TIME_ZONE})</defaultValueExpression>

</parameter>


and in my testfield expression i use

<textFieldExpression>$P{DateFormatter}.format($F{WORK_PLAN_CREATED_TS})</textFieldExpression>

 

my end result is that i am not able to convert the date into respective timezone. please do the needfull

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...