Date to String and String to Date Error Java : <p>I am changing my date to String and again from string to date but the date after converting from string to date is different than before .See the Code</p>

<pre><code>import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JOptionPane;

public class DateChange {

public static void main(String[] args) {

    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/YYYY");
    Date date = new Date();
    String dateString = dateFormat.format(date);

    Date currentDate = null;
    try {

        currentDate = dateFormat.parse(dateString);

        System.out.println(date + " \n" + currentDate);

    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}
</code></pre>

<p>Here if date object has value Mon Sep 04 12:51:33 IST 2017 </p>

<p>Than currentDate has          Sun Jan 01 00:00:00 IST 2017</p>

<p>I know something is wrong with the code and I am unable to figure it out.So please point it out for me.</p>

<p>Thanks</p>
