^(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29))$)|(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))$Description:   This expression validates dates in the y/m/d format from 1600/1/1 - 9999/12/31. Follows the same validation rules for dates as my other date validator (m/d/y format) located in this library.  
Matches:  [04/2/29], [2002-4-30], [02.10.31]  [ More Details]  
Non-Matches:  [2003/2/29], [02.4.31], [00/00/00]

解决方案 »

  1.   

    if((year%4==0&&year%100!=0)||(year%400==0))
    System.out.println(year+"isaleapyear.");
    else
    System.out.println(year+"isnotaleapyear.");
      

  2.   

    function isLeapYear(year) 

     if((year%4==0&&year%100!=0)||(year%400==0)) 
     { 
     return true; 
     }   return false; 

      

  3.   

    if((year%4==0&&year%100!=0)||(year%400==0))
      

  4.   


       功能:日期输入合法性校验
       参数:年,月,日
       返回值:true or false
       以前做的还行比较好用function verifyDate(sYear, sMonth, sDay) {
        if(isNaN(sYear) || isNaN(sMonth) || isNaN(sDay)){
            return false;
        }    var calendarPMM = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
        var calendarRMM = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);    var iYear = sYear/1;
        var iMonth = sMonth/1;
        var iDay = sDay/1;    if( iYear <= 0 || iMonth <= 0 || iDay <= 0 || iMonth > 12){
            return false;
        }    if( iYear%4 == 0 ){
            if( iYear%100 == 0 && iYear%400 != 0 ){
                if( iDay > calendarPMM[iMonth-1] ){
                    return false;
                }
            }else{
                if( iDay > calendarRMM[iMonth-1] ){
                    return false;
                }
            }
        }else{
            if( iDay > calendarPMM[iMonth-1] ){
                return false;
            }
        }
        return true;}