title: I want difference between two date in java?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1555262/calculating-the-difference-between-two-java-date-instances">Calculating the Difference Between Two Java Date Instances</a><br>
    <a href="https://stackoverflow.com/questions/3491679/how-to-calculate-difference-between-two-dates-using-java">how to calculate difference between two dates using java</a>  </p>
  </blockquote>
  
  
  
  <p>I have try to difference two date by using some example but I have not got correct answer.</p>
  
  <pre><code>java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
   java.util.Date date1 = df.parse("2012-09-14 15:26:14+00");
   java.util.Date date2 = df.parse("2012-08-30 15:26:14+00");
   long diff = Math.abs(date2.getTime() - date1.getTime());
   System.out.println("millisecond="+diff);
  </code></pre>
  
  <p>I want month difference also but it didnt gave me. It is giving me difference days,hours,minute and seconds but not month.What am i doing wrong? Please help me</p>
  
  <p>Edit:</p>
  
  <pre><code>java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
   java.util.Date date1 = df.parse("2012-09-30 15:26:14+00");
   java.util.Date date2 = df.parse("2012-08-30 15:26:14+00");
   long diff = Math.abs(date2.getTime() - date1.getTime());
   System.out.println(date2.getTime()+"date2");
   System.out.println(date1.getTime()+"date1");
   System.out.println("millisecond="+diff);
   diff=diff/1000;
   System.out.println("second="+diff);
   long days=diff/86400;
   days=days%86400;
   long hours=diff/3600;
   hours=hours%3600;
   long min=diff/60;
   min=min%60;
   hours=(hours-(24*days));
   String time=days+":"+hours+":"+min;
   System.out.println(time);
  System.out.println("days="+days+":"+"hours="+hours+":"+"minutes"+min);
  </code></pre>
  
  <p>This is what i am trying to do.</p>