Q:

Calculating the week day, by entering specific date

I need to create a program which shows the day of week, when you enter the specific date to console.
Here's the code I've written, but still not working, why would it be?
public class CalculateDay{

     public static void main(String []args){

         int m = Integer.parseInt(args[0]);
         int d = Integer.parseInt(args[1]);
         int y = Integer.parseInt(args[2]);

         System.out.println("Finding day of week for "+m+"-"+d+"-"+y);

         int yo = y - ((14-m)/12);

         int x = yo + yo/4 - yo/100 + yo/400;

         int mo = m + 12*((14-m)/12) -2;

         int dayOfWeek = (d + x + (31*mo)/12)%7;

         String dayString;

         switch(dayOfWeek){
            case 0:    dayString = "Sunday";
                        break;
            case 1:    dayString = "Monday";
                        break;
            case 2:    dayString = "Tuesday";
                        break;
            case 3:    dayString = "Wednesday";
                        break;
            case 4:    dayString = "Thursday";
                        break;
            case 5:    dayString = "Friday";
                        break;
            case 6:    dayString = "Saturday";
                        break;            
            default:    dayString = "Could not find";
         }

        System.out.println(dayString);
     }
}

A:

Try this:
int m = Integer.parseInt(args[0]);
int d = Integer.parseInt(args[1]);
int y = Integer.parseInt(args[2]);

System.out.println("Finding day of week for "+m+"-"+d+"-"+y);

Calendar cal = new GregorianCalendar(y, m, d);
System.out.println("DAY_OF_WEEK: " + cal.get(Calendar.DAY_OF_WEEK));

