zoukankan      html  css  js  c++  java
  • Flex中计算某个月有多少天


    /**
    			 *计算一个月中有多少天
    			 * @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

  • 相关阅读:
    10.30 afternoon
    10.29 afternoon
    10.29 morning

    10.27 noip模拟试题
    codevs 3052 多米诺 二分图匹配
    poj 1849 Two
    10.26 noip模拟试题
    10.25 noip模拟试题
    .NET Core EF 版本问题
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3010925.html
Copyright © 2011-2022 走看看