Jump to content
We've recently updated our Privacy Statement, available here ×

Changing color of font when date is expired


evanrheenen

Recommended Posts

Hi,

I'm new to iReport and have a question that is probabely asked number of times, but i cannot find the answer.

I have a field "End of Support" (type "date") which i retrieved from my postgresql database.  If that date is in the past, i want to change the color of the font to "red", otherwise leave it black.

A second option would be if that field "End of Support" is within 6 months from now i would like to color it "orange".

For the first option i tried the following in the "Print when expression":

((System.currentTimeMillis() > $F{End of Support}) ?
    new String("<style forecolor='red'>"
        + String.valueOf($F{End of Support})
        + "</style>") :
    String.valueOf($F{End of Support}))
But this didn't work
 
I think i need to define 2 styles ?  Please explain how to solve this problem (1 + 2)
Thanks
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

you can try putting those 3 in different text fields in the printWhereExpression

(new Date() > $F{End of Support} AND new org.joda.time.DateTime().plusMonths(6).toDate() < $F{End of Support})

(new Date() <= $F{End of Support})

(new org.joda.time.DateTime().plusMonths(6).toDate() > $F{End of Support})

 

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