日..期..问..题.. 如何获得某年某周的起始日期和结束日期   比如2005年第10周的起始日期和结束日期

解决方案 »

  1.   

    public class FirstDate{
        public static Boolean leapYear(int y)
        {
            if(y%4==0&&y%100!=0||y%400==0)
                return true;
            else return false;
        }
        public static int leap(int y)
        {
            if(leapYear(y))
                return 1;
            else return 0;
        }
        public static int yearFirstDay(int y)
        {
            int total=y-1+(y-1)/4-(y-1)/100+(y-1)/400+1;
            return total%7;
        }
        public static int monthFirstDay(int y,int m)
        {
            int total=yearFirstDay(y);
            for(int i=0;i<m;i++)
                total+=monthTab[leap(y)][m];
            return (total-1)%7;
        }
    }
    ===============================================
    得到一年第一天的日期和每个月第一天的日期,星期的自己写吧。