Java Date and Time

  • + 1 comment

    /* * Complete the 'findDay' function below. * * The function is expected to return a STRING. * The function accepts following parameters: * 1. INTEGER month * 2. INTEGER day * 3. INTEGER year */

    public static String findDay(int month, int day, int year) {
        Calendar g = new GregorianCalendar();
        g.set(Calendar.YEAR, year);
        g.set(Calendar.MONTH, month-1);
        g.set(Calendar.DAY_OF_MONTH, day);
        return g.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()).toUpperCase();
    }