title: How to find difference in Joda time
body: <p>I am trying to use the <code>Interval</code> class of Joda Time but I am unable to use its constructor. It does not take the format.</p>
  
  <p>I am trying to extract two <code>DateTime</code> from mysql DB in the format <code>yyyy-MM-dd HH:mm:ss</code> and it is retrieved in <code>String</code> format. I am trying to convert it into date format but the interval class is unable to take date formats. Please help what should I use???</p>
  
  <pre><code>    String text = "2011-10-02 18:48:05";
      String text2 = "2011-10-02 18:50:05";
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  try {
              Date olddate=sdf.parse(text);
              Date newdate=sdf.parse(text2);
              System.out.println(olddate);
              System.out.println(newdate);
  //            Interval interval = new Interval(olddate, newdate);
  
  
  
          } catch (ParseException ex) {
              JOptionPane.showMessageDialog(null, "Error at Timestamp subtract Format function Dategenerator" + ex.getMessage());
  
          }
  </code></pre>