Good morning. I am writing a calendar function, where there are 2 arguments a month and a year. The function returns a 2-dimensional array and builds a calendar for a specific year. I compare localDate with the key if the return value is the same. How can I transfer it to build my calendar correctly?
package lang; import java.io.IOException; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class GetFunWithJavaLang { public static int[][] Cal(int month, int year) throws IOException { LocalDate localDate = LocalDate.of(year, month, 1); System.out.println(localDate.getDayOfWeek()); HashMap<String , Integer> map = new HashMap<String , Integer>(); map.put("SUNDAY", 7); map.put("MONDAY", 1); map.put("TUESDAY", 2); map.put("WEDNESDAY", 3); map.put("THURSDAY", 4); map.put("FRIDAY", 5); map.put("SATURDAY", 6); for(Entry entry: map.entrySet()) { String key = (String) entry.getKey(); if (key.equals(localDate)) { int value = (int) entry.getValue(); } } int[] days = {31,28,31,30,31,30,31,31,30,31,30,31}; int[][] calen = new int[6][7]; int k=0; for (int i = 0 ; i<calen.length ; i++) { for (int j=0 ; j<calen.length ; j++) { if (days[month-1] > k) { k++; calen[i][j] = k; } } } for (int i = 0; i < calen.length; i++, System.out.println(" ")) { for (int j = 0; j < calen[i].length; j++) { System.out.print(calen[i][j] + " "); } } return calen; } public static void main(String[] args) { Cal(1, 1998); } }