title: How to convert date strings to different format using Calendar
body: <p>I am changing to <code>Calendar</code> from the deprecated <code>Date</code> library, I need to compare different time string objects. </p>
  
  <p>How can I transform the time string <code>(xx:xx:xx)</code> to a full date <code>(Tue Feb 03 21:02:25 CET 2015)</code> using <code>Calendar</code>?</p>
  
  <p>I tried:</p>
  
  <pre><code>import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  
  public class Test2 {
  
      public static void main(String[] args) throws ParseException {
          // Date date = new SimpleDateFormat("HH:mm:ss").parse("21:20:00"); // Date ist 1970!
          // System.out.println(date.toString());
  
          Calendar cal = Calendar.getInstance();
          SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
          SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss | dd.MM.yy");
          cal.set(cal.YEAR, cal.MONTH, cal.DATE, 21, 20, 00);
          System.out.println(sdf2.format(cal.getTime()));
  
      }
  
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  
  public class Test2 {
  
      public static void main(String[] args) throws ParseException {
          // Date date = new SimpleDateFormat("HH:mm:ss").parse("21:20:00"); // Date ist 1970!
          // System.out.println(date.toString());
  
          Calendar cal = Calendar.getInstance();
          SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
          SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss | dd.MM.yy");
          cal.setTime(sdf.parse("21:20:00"));
          cal.set(Calendar.YEAR, Calendar.MONTH, Calendar.DATE);
          System.out.println(sdf2.format(cal.getTime()));
  
      }
  
  }
  </code></pre>
  
  <p>But they return, respectively: <code>21:20:00 | 05.03.01</code></p>
  
  <p>I want to be able to compare the result with other "full date objects" like <code>Tue Feb 03 21:02:25 CET 2015</code>.</p>