SimpleDateFormat is giving wrong Date : <p><strong>I am inputting a specific date (dd/MM/yyyy) , while displaying it the Output is something else.</strong></p>

<pre><code>import java.text.*;
import java.io.*;
import java.util.*;
class InvalidUsernameException extends Exception       //Class InvalidUsernameException
{
    InvalidUsernameException(String s)
    {
        super(s);
    }
}

///////////////////////////////////////////////////////////////////////////////////////////
class InvalidPasswordException extends Exception      //Class InvalidPasswordException
{
    InvalidPasswordException(String s)
    {
        super(s);
    }
}
///////////////////////////////////////////////////////////////////////////////////////////
class InvalidDateException extends Exception      //Class InvalidPasswordException
{
    InvalidDateException(String s)
    {
        super(s);
    }
}

///////////////////////////////////////////////////////////////////////////////////////////
class EmailIdb1                                   //Class Email Id b1
{
    String username, password;
    int domainid;
    Date dt;

    EmailIdb1()
    {
        username = "";
        domainid = 0;
        password = "";
        dt = new Date();
    }


    EmailIdb1(String u, String pwd, int did, int d, int m, int y)
    {
        username = u;
        domainid = did;
        password = pwd;
        dt = new Date(y,m,d);       // I think There is a problem
        SimpleDateFormat formater = new SimpleDateFormat ("yyyy/MM/dd"); //Or there can be a  problem

        try{
            if((username.equals("User")))
            {
                throw new InvalidUsernameException("Invalid Username");
            }
            else if((password.equals("123")))
            {
                throw new InvalidPasswordException("Invalid Password");
            }
            else{
                System.out.println("\nSuccesfully Login on Date : "+formater.format(dt));

            }           
        }
        catch(Exception e)
        {

        }
    }
}


///////////////////////////////////////////////////////////////////////////////////////////
class EmailId                                    //Class Email Id
{
    public static void main(String args[])
    {
        int d,m,y,did;
        String usn,pwd;
        EmailIdb1 eml;

        try{
            usn = args[0];
            pwd = args[1];
            did = Integer.parseInt(args[2]);
            d   = Integer.parseInt(args[3]);
            m   = Integer.parseInt(args[4]);
            y   = Integer.parseInt(args[5]);

            switch(m)
            {
                case 2: if(d==29 &amp;&amp; y%4 == 0)
                        {
                            eml = new EmailIdb1(usn,pwd,did,d,m,y);
                        }
                        else if(d&lt;=28 &amp;&amp; d&gt;=1)
                        {
                            eml = new EmailIdb1(usn,pwd,did,d,m,y);
                        }
                        else{
                            throw new InvalidDateException("Wrong Date.");
                        }
                        break;

                case 1: case 3: case 5: case 7: case 8: case 10:
                case 12: if(d&gt;=1 &amp;&amp; d&lt;=31)
                         {
                            eml = new EmailIdb1(usn,pwd,did,d,m,y);
                         }
                         else
                         {
                             throw new InvalidDateException("Invalid Date");
                         }
                    break;
                case 4: case 6: case 9:
                case 11: if(d&gt;=1 &amp;&amp; d&lt;=30)
                         {
                             eml = new EmailIdb1(usn,pwd,did,d,m,y);
                         }
                         else
                         {
                             throw new InvalidDateException("Invalid Date");
                         }
                    break;
                default : throw new InvalidDateException("Invalid Date");
            }


        }
        catch(InvalidDateException ed)
        {
            System.out.println(ed);
        }
    }
}
</code></pre>

<p>Me and my two friends have similar kind of problem. Don't know why This is Happening. My teacher also couldn't find what's the problem</p>

<p>The Output Should be</p>

<pre><code>Successfully Login on Date : 1994/05/04
</code></pre>

<p>As the Input Is</p>

<pre><code>Successfully Login on Date : 3894/06/04
</code></pre>
