The Code you have used cannot be implemented in any standard date operations because there are many cases like leap year etc.
Try to use java.util.Calendar for date operations that needs to know the details like Week Days, Months etc.
For Even More Complex date function Use JODA Calendar. Joda Calendar is fast and have a lot of operations like no of days between two days etc. You can Look into the above link for more details.
For Now you can use this
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date) ;
int i=calendar.get(Calendar.DAY_OF_WEEK);
Here the value of i will be from 1-7 for Sunday to Saturday.