Udi
Udi

Reputation: 618

Java Calendar - getMinimalDaysInFirstWeek but not from get instance

i'm trying to send month as int to a method that will bring me back the minimal days of the first week. the problem is it bring me back always the same answer. it seems it ignore from my calendar i created in order to do so. please advice:

MyPanel send the int to the method:

public JPanel getCenter()

{
    //int curMonth = getMonthFromCombo();
    int curMonth = 4;
    int curYear = getYearFromCombo();
    int countDays = 1;
    int MinDaysFirstWeek = myDate.getMinDaysFirstWeek(curYear, curMonth - 1, 1);
    System.out.println("min days are:" + MinDaysFirstWeek);
    int daysInCurMoth = myDate.getHowManyDaysInCurMonth(curYear , curMonth - 1, 1);
    System.out.println("current month:" + curMonth);
    System.out.println("days in current month:" + daysInCurMoth);
    JPanel center = new JPanel();

method needs to send back the minimal days of the first week to the panel:

public int getMinDaysFirstWeek(int curYear , int curMonth , int day)
{
    Calendar forDay = new GregorianCalendar(curYear, curMonth, day);
    minDaysInFirstWeek = forDay.getMinimalDaysInFirstWeek();
    return minDaysInFirstWeek;
}

Upvotes: 1

Views: 196

Answers (1)

Udi
Udi

Reputation: 618

apparently i had a mistake like Christian Hujer mention. the method getMinimalDaysInFirstWeek() doesn't support what i ment to do.

i edit the code:

public int getDayInFirstWeek(int curYear , int curMonth , int day)
{
    Calendar forDay = new GregorianCalendar(curYear, curMonth, day);
    dayFirstWeek = forDay.get(GregorianCalendar.DAY_OF_WEEK);
    return dayFirstWeek;
}

now it brings me back the first day of the week of each month the user input. thanks.

Upvotes: 1

Related Questions