I would recommend using the java.util.Formatter '-' flag for Left Justify. From the Javadoc:
'-' '\u002d' Left justifies the output. Spaces ('\u0020') will be added at the end of the converted value as required to fill the minimum width of the field.
So, if we apply this to your example:
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar = new GregorianCalendar(2014, 07, 18);
Date startDate = calendar.getTime();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yy");
String formatted = simpleDateFormat.format(startDate);
String result = "";
String header2 = String.format("%s %20s %20s %20s%n", "Account", "Date", "Hours", "Skill");
result += header2;
result += "-----------------------------------------------------------------------\n";
result += String.format("summary %20s%n", formatted);
result += String.format("%-40s %4d%n", "Totabl Billable:", 40);
result += String.format("%-40s %4d%n", "Total Non-Billable:", 0);
result += String.format("%-40s %4d%n", "Total Hours:", 40);
System.out.println(result);
}
Will pad the first input (the row label) with spaces to match a fixed width (40 in this case). This will produce:
Account Date Hours Skill
-----------------------------------------------------------------------
summary 08/18/14
Totabl Billable: 40
Total Non-Billable: 0
Total Hours 40
This gives the added benefit of working for dynamic row labels since it automatically pads to the specified width regardless of the length of the label. It will be more flexible then trying to calculate the space for every possible label.