/** *计算一个月中有多少天 * @author wangfeng * @date 2013年4月9日 15:47:58 */ private function dayCount(year:Number,month:Number):int { var result:int = 0; if(1==month || 3==month || 5==month|| 7==month || 8==month || 10==month || 12==month) { result = 31; }else if(4==month || 6==month || 9==month || 11==month) { result = 30; }else if(2==month) { if((year % 4 == 0 && year %100 !=0) || year % 400 == 0) { result = 29; }else { result = 28; } } return result; }
在Flex中创建一个日期是本月最后一天的Date对象:
private var endDate:Date = new Date(new Date().getFullYear(),new Date().getMonth(),dayCount(new Date().getFullYear(),new Date().getMonth()+1));
注意,getMonth()方法返回的是0到11.0代表1月。2代表2月。依次类推。因此,在参数传递的时候,要在getMonth()上加1