java新手,程序能正常运行,但结果不对

输入年份、月份,打印出月历的小程序。源代码全是照着教程打上去的,程序能正常运行,但结果不对。输入2015年8月,月历是对的;输入2014年1月,正确的结果1号应该是星期三,但是显示的结果却是星期四。
import java.util.Scanner;
public class PrintCalendar {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    Scanner input =new Scanner(System.in);
    System.out.print("请输入年份(格式如2001):");
    int year = input.nextInt();

    System.out.print("请输入月份(格式1-12):");
    int month = input.nextInt();
    printMonth(year,month);
}

public static void printMonth(int year,int month){  //主方法
    printMonthTitle(year,month);
    printMonthBody(year,month);
}

public static void printMonthTitle(int year,int month){  //打印排头
    String MonthName=getMonthName(month);
    System.out.println("          "+ year +" 年 " + MonthName);
    System.out.println("   日  一  二  三  四  五  六");
}

public static void printMonthBody(int year,int month){  //打印表格主体
    int startDay=getStartDay(year,month);
    int numberofDaysInMonth=getNumberofDaysInMonth(year,month);
    int i=0;
    for(i=0;i<startDay;i++)
        System.out.print("    ");
    for(i=1;i<=numberofDaysInMonth;i++){
        System.out.printf("%4d",i);
        if((i+startDay)%7==0)
            System.out.println();
    }
}

public static String getMonthName(int month){  //得到月份名
    String s="";
    switch(month){
        case 1:s="1 月";break;
        case 2:s="2 月";break;
        case 3:s="3 月";break;
        case 4:s="4 月";break;
        case 5:s="5 月";break;
        case 6:s="6 月";break;
        case 7:s="7 月";break;
        case 8:s="8 月";break;
        case 9:s="9 月";break;
        case 10:s="10 月";break;
        case 11:s="11 月";break;
        case 12:s="12 月";
    }
    return s;
}



public static int getStartDay(int year,int month){  //得到开始天数(一号是星期几)
    final int START_DAY_FOR_JAN_1_1800 = 3;  //设置一个常量1800年1月1日是星期3
    int TotalNumberofDays =getTotalNumberofDays(year,month);
    return (TotalNumberofDays+START_DAY_FOR_JAN_1_1800) % 7; 
    //如果不+3,返回值=0时是星期三
}

public static int getTotalNumberofDays(int year,int month){  //得到总天数
    int total=0;
    for(int i=1800;i<year;i++){   //累加每年的天数
        if(isLeapYear(i)) 
            total=total+366;
        else total=total=365;
    }
    for(int i=1;i<month;i++){   //累加当年的月总天数
        total=total+getNumberofDaysInMonth(year,i);
    }
    return total;

}

public static int getNumberofDaysInMonth(int year,int month){  //得到当月天数
    if(month==1 ||month==3 ||month==5 ||month==7 ||month==8 ||month==10 ||month==12)
        return 31;
    if(month==4 ||month==6 ||month==9 ||month==11)
        return 30;
    if(month==2) return isLeapYear(year)?29:28;
    return 0;//如果输入的月份值有问题
}

public static boolean isLeapYear(int year){  //是否是闰年
    /*  如果能被4整除,且不能被100整除,则为闰年
        如果能被100整除,且能被400整除,则为闰年
    */
    return year %400==0 || (year %4 == 0 && year % 100 != 0);
}
}

不是,你说的意思,应该是数据的凑巧性,你的for循环的功能是累加每年的天数,而当碰到非闰年的时候,你就直接把total赋值成了365,当i=2013时,total=365,也就说你的循环等效成了一个赋值语句,total=365,显然没有实现天数的累加,

for(int i=1800;i<year;i++){   //累加每年的天数
            if(isLeapYear(i)) 
                total=total+366;
            else total=total+365;
        }

把else里面的改成+

把else里面的改成+
的确运行后是正确的结果,但是这是为什么呢?闰年就+366天,不是闰年就+1天吗?

else total=total=365;
改为:else total+=365;

要实现什么功能?哪里不对了