Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java: Date Checking

Name: Anonymous 2011-04-08 0:01

Why does this not work; why do I suck at programming;


public static boolean validDate(int m, int d, int y){
        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12){
            if (d < 1 || d > 31)
                return false;
            return true;
        }else if (m == 4 || m == 6 || m == 9 || m == 11){
            if (d < 1 || d > 30)
                return false;
            return true;
        }else if (m == 2){
            if ( d < 1 || d > 29)
                return false;
            if (d == 29 && leapYear(y))
                return false;
            return true;
        }
        return false;
    }


it doesn't even work for absurdly wrong dates like 1234/1234/1234

Name: Anonymous 2011-04-08 4:21

>>12
Back to school, please

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List