evanrheenen Posted January 19, 2015 Share Posted January 19, 2015 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 More sharing options...
matthias.p Posted January 20, 2015 Share Posted January 20, 2015 Maybe you can setup two text fields with different style and just add an expression when to display the text or not. Link to comment Share on other sites More sharing options...
evanrheenen Posted January 20, 2015 Author Share Posted January 20, 2015 Yes, but how should the test looks like ((System.currentTimeMillis() > $F{End of Support}) ? .. : ..) is not working (cast error). If i can get the test correct, the font will probabely change color. Link to comment Share on other sites More sharing options...
jacobs_1 Posted January 22, 2015 Share Posted January 22, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now