title: How to convert string to datetime in java using joda time
body: <p>I am currently working on converting from date to string. After that I convert that string to datetime. But it error. Anyone can help me?</p>
  
  <p>Here is the code.</p>
  
  <pre><code>import org.joda.time.DateTime
  import org.joda.time.format.DateTimeFormat
  import org.joda.time.format.DateTimeFormatter
  import java.util.Date;
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  
  
  SimpleDateFormat outFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
  String dt1 = outFormat.format(date1);
  
  
  DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
  DateTime dt = formatter.parseDateTime(dt1);
  </code></pre>