jvway Posted December 22, 2010 Share Posted December 22, 2010 Hi all,So I've got a crosstab working that has the days of the week in the header rows. Ideally I'd like to shade the columns when the header is a weekend day. Not sure how to affect other cells with a conditional in one cell so that's a question. But also what's the Groovy expression to determine the day of the week?I've tried a number of ways to formulate the expression but none have worked. I get very obtuse errors that I can post but if anyone's got some direction on this I'd appreciate it.Thanks,Jerry Link to comment Share on other sites More sharing options...
zhuolin Posted December 22, 2010 Share Posted December 22, 2010 Just an idea, I did not try that in practice. Why not write a script to determine the weekday. Give a input day of week and return a boolean or something you want. You can always reuse this code. To the shade of column, is 'styles' a good way to solve the problem. Depending on the output value of your script, different styles will be actived. Link to comment Share on other sites More sharing options...
cbarlow3 Posted December 22, 2010 Share Posted December 22, 2010 Although most methods in java.util.Date are deprecated in favor of the newer Calendar, GregorianCalendar, etc. (and Groovy inherits much from Java), I found no trouble using the getDay() method on any java.util.Date parameter or field. For example, I made a java.lang.Integer variable called dayOfWeek and defined the Variable Expression as ($F{POSTING_DATE}).getDay(), and it returned a number from 0 (Sunday) to 6 (Saturday). Naturally, you could also define it in such a way that it would print out the day of the week or abbreviation, but since you're using it to test a condition, I figure the number is probably all you need.Carl Link to comment Share on other sites More sharing options...
jvway Posted December 22, 2010 Author Share Posted December 22, 2010 Oh, of course. I wasn't thinking that the integer value had to do with the number of the day in the week. so 5 - Saturday...My thought patterns lately lean so much to the PHP/MySQL world.Excellent. Thanks Link to comment Share on other sites More sharing options...
cbarlow3 Posted December 22, 2010 Share Posted December 22, 2010 It seems that month of the year and day of the week are implemented numerous ways in different langauges, so do some testing. My testing seems to show that the .getDay() method as interpreted by Groovy returns a value from 0 = Sunday to 6 = Saturday. JavaScript and actual Java may differ. I saw one method that returned 1 through 7 instead of 0 through 6, and I think it had 1 as Sunday, but my test from this morning shows 0 = Sunday, 1 = Monday, .... 6 = Saturday.Carl 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