title: Regarding Date class in java
body: <p>Whenever I am providing different date to the program it's always gives output as wrong date. Its showing the previous year December month date.</p>
  
  <pre><code>import java.text.*;
  import java.util.*;
  
  public class Sample {
  
      public static void main(String args[])throws Exception 
      {
          Scanner s = new Scanner(System.in);
          System.out.println("Enter the details");
          String str = s.nextLine();
          String v[] = str.split(",");
  
          System.out.println(v[0]);
          System.out.println(v[1]);
          System.out.println(v[2]);
          try{
              Date d1 = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss").parse(v[0]);
              Date d2 = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss").parse(v[1]);
  
  
              System.out.println(v[0]+"  =  "+ d1); 
              System.out.println(v[1]+"  =  "+d2); 
          } catch(Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>run:</p>
  
  <pre><code>Enter the details
  06/05/2018 02:17:52,06/02/2015 03:15:33,Sourav
  06/05/2018 02:17:52
  06/02/2015 03:15:33
  Sourav
  06/05/2018 02:17:52  =  Sun Dec 31 02:17:52 IST 2017
  06/02/2015 03:15:33  =  Sun Dec 28 03:15:33 IST 2014
  BUILD SUCCESSFUL (total time: 3 seconds)
  </code></pre>