Παράδειγμα: εύρεση ημέρας (main)


  public static void main(String[] args) throws Exception {
      // Are appropriate arguments given?
      if (args.length != 3) {
        System.err.println("usage: FindDay year month day");
        System.exit(1);
      }

      // Parse year, month, day
      int year = Integer.parseInt(args[0]);
      int month = Integer.parseInt(args[1]) - 1;
      int monthDay = Integer.parseInt(args[2]);

      // Set the calendar and calculate the day name
      var d = new GregorianCalendar(year, month, monthDay);
      String dn = weekDayName(d.get(Calendar.DAY_OF_WEEK));

      // Print the day name
      System.out.println(dn);
    }