title: java.lang.IllegalArgumentException: Bad class: class java.util.GregorianCalendar
body: <p>I received this exception while using <code>GregorianCalendar</code></p>
  
  <p><code>java.lang.IllegalArgumentException: Bad class: class java.util.GregorianCalendar</code></p>
  
  <p>Who know how to fix,</p>
  
  <p>Please help me.</p>
  
  <p>p/s : I used the following code :</p>
  
  <pre><code>Calendar someDate = GregorianCalendar.getInstance();
          someDate.add(Calendar.DAY_OF_YEAR, -7);
          SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          String formattedDate = dateFormat.format(someDate);
  </code></pre>
  
  <p><strong>UPDATED</strong> I should be use this line to achieve the date time :</p>
  
  <p><code>String formattedDate = dateFormat.format(someDate.getTime());</code></p>