I'd like to create a formatted chart as the one displayed below:
The character count in each of the fields is 4, 12, 17, 40 and 4 respectively. The fields are also left-justified.
By using the code that I posted below, my result looks like this:
Code snippet for formatting:
for (Tasks examined : shortList) {
String yesNo = examined.isDone() == true ? "yes" : "no";
System.out.printf("%1$-4s" + "| " + "%2$tY.%<tm.%<-12td."
+ "| " + "%3$-17s" + "| " + "%4$-40s" + "| " + yesNo + "\n"
, examined.getNumber(), examined.getDeadline()
, importanceLevel, examined.getName())
}
The variable types are:
examined.getNumber() //integer
examined.getDeadline() //DateTime
importanceLevel //String
examined.getName() //String
I've studied the Formatter class in the JavaDocs here. But I have couldn't solve the problem.
The main issue here, is the dot (.) at the end of the 'date' field. It shouldn't have all that whitespace between the date and the full-stop.
I wanted to organize the width of the 'date' element, with the -12 flag, but that just cut the rest as the final dot above.
How could this be solved?

