zoukankan      html  css  js  c++  java
  • 呵呵,日期小小技巧

    Code
            //获取当前日期所在月份的最后一天
            public     DateTime GetLastDayOfMonth(DateTime dt)
            {
                
    if (dt.Month==1 || dt.Month==3 || dt.Month==5 || dt.Month==7 || dt.Month==8 || dt.Month==10 || dt.Month==12)
                    
    return new DateTime(dt.Year,dt.Month,31);
                
    else
                {
                    
    if (dt.Month==4 || dt.Month==6 || dt.Month==5 || dt.Month==9 || dt.Month==11)
                        
    return new DateTime(dt.Year,dt.Month,30);
                    
    else
                    {
                        DateTime leapyear;
                        
    try
                        {
                            leapyear  
    =new DateTime(dt.Year,dt.Month,29);
                        }
                        
    catch (Exception e)
                        {
                            leapyear
    =new DateTime(dt.Year,dt.Month,28);
                        }
                        
    return leapyear;
                        
                    }
                }
            }

    这个太落后了吧,

    最简单算法是,下个月的1号减一天就到了当前月份的最后一天

  • 相关阅读:
    JMeter:全面的乱码解决方案
    代码静态扫描工具sonar
    jmeter接口测试
    MVC模式
    Android--HttpClient
    android SQLite使用SQLiteOpenHelper类对数据库进行操作
    反射
    列约束
    MVC的处理过程
    android项目中values中几个文件的作用
  • 原文地址:https://www.cnblogs.com/panzhilei/p/1454665.html
Copyright © 2011-2022 走看看