반응형

달, 일 범위 체크 후 범위내에 있으면 true리턴 없으면 false리턴

private bool CheckVaildDate(string strDate)
        {
            if (strDate.Length != 8)
                return false;

            string strMonth;
            string strDay;

            strMonth = strDate.Substring(4, 2);
            strDay = strDate.Substring(6, 2);

            int nMonth = Convert.ToInt32(strMonth);
            int nDay = Convert.ToInt32(strDay);

            if (nMonth < 1 || nMonth > 12)
            {
                return false;
            }

            if (nDay < 1 || nDay > 31)
            {
                return false;
            }

            return true;
        }
반응형

+ Recent posts