I have to output a Julian Calendar in java. I printed out each month, however I am unsure how to fix the row lengths to correspond to each month. For example, February, April, June, September and November do not have 31 days. This is my code so far:
import java.text.DateFormatSymbols;
public class testing {
public void Day() {
System.out.println();
for (int i = 1; i <= 31; i++) {
System.out.println(String.format("%2s", i));
}
}
public void MonthNames() {
String[] months = new DateFormatSymbols().getShortMonths();
for (int i = 0; i < months.length; i++) {
String month = months[i];
System.out.printf(month + " ");
//System.out.printf("\t");
}
}
public void ColRow() {
int dayNum365 = 1;
int array [][] = new int[31][12];
System.out.println();
for (int col = 0; col < 12; col++) {
for (int row = 0; row < 31; row++) {
array[row][col] += (dayNum365);
dayNum365++;
}
}
for (int col = 0; col < array.length; col++) {
for (int row = 0; row < array[col].length; row++) {
System.out.printf("%03d", array[col][row]);
System.out.print(" ");
}
System.out.println();
}
}
public static void main(String[] args) {
testing calendar = new testing();
calendar.MonthNames();
calendar.ColRow();
}
}