Jump to content
Changes to the Jaspersoft community edition download ×

Group by Month in timezone


jhickling

Recommended Posts

Could someone please tell me how to correctly group by Month while allowing for multiple timezones in Jaspersoft?

Our Mysql database is in UTC time, and I am in Australia, UTC +10:00, so a date that is '1st May 2015 08:00' for me is '30th April 2015 22:00' in the database. Using patterns in the designer converts UTC dates to my timezone correctly, but I cannot use one of these inbuild patterns in a group expression (at least not to my knowledge). How can I group by month while taking into account the timezone?

Thanks,

Justin

UPDATE, I figured it out.

Create a parameter (E.g. $P{DateFormatter}, not for prompting, class of DateFormat) in the report with the following default expression:

$P{REPORT_FORMAT_FACTORY}.createDateFormat("dd/MM/yy", $P{REPORT_LOCALE},$P{REPORT_TIME_ZONE})[/code]

This could be any date format, such as "MMMM, yyyy", etc etc.

Then in the Group Expression its as simple as writing $P{DateFormatter}.format($F{TheDate}). This will then correctly group according to the local timezone, as opposed to the SQL database timezone.

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...