I'm trying to print out a basic header in Groovy. I need the first line to have the date left-justified, with the name of the institution centered, and page number right-justified. On the second line I need a report description centered with the name of the report right-justified. I couldn't get an example of the output to paste in correctly to this text field so hopefully this description will suffice, it seems pretty standard.
I retrieve the date, institute name, report description and report name from the database. So those fields are variable in size. I thought something like this would work but it does not right-justify or center correctly:
println String.format("%-${maxColumns}s %s %${maxColumns}s", dbDateTime.format('MMMMM d, yyyy'), institution, 'Page: 1')
println String.format("%-${maxColumns}s %s %${maxColumns}s", '', jobTitle, programName)
I set maxColumns to 80, the character limit. Any help is appreciated, I've searched high and low for this! Thanks!