Sign in to follow this  
johnnyBravo

Java, how to get starting day of month?

Recommended Posts

you could use a gregorian calendar, perhaps like this :
[source lang = "java"]
public class MC {
public void ShowDaysinMonth(int year, int month) {
GregorianCalendar mg = new GregorianCalendar();
mg.set(Calendar.YEAR, year);
mg.set(Calendar.MONTH, month);
mg.set(Calendar.DATE, 1);
return (int)mg.get(Calendar.DAY_OF_WEEK);
}
}


it returns an int of the starting day (1-7 or 0-6, can't remember) naturally, you may have to modify that. hope that helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this