title: Convert from string "yyyyMMdd" to Calendar in java
body: <p>I need to use Calendar class. This is my code, but it has an error certainly. How can I fix it?</p>
  
  <pre><code>String stringdate = "20161129";
  String pattern = "yyyyMMdd";
  Date date = new SimpleDateFormat(pattern).parse(stringdate);
  Calendar cal = Calendar.getInstance();
  cal.setTime(date);
  </code></pre>