• Advertisement
Sign in to follow this  

Java, how to get starting day of month?

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm using java and need to get the starting day of a month, eg this month starting day is friday, and next month is monday i think. any ideas? thanks

Share this post


Link to post
Share on other sites
Advertisement
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
Sign in to follow this  

  • Advertisement