title: Why is my Java Calendar.setTime() sporadically setting wrong times?
body: <p>Using this code below, I noticed that sometimes the date gets formatted incorrecty. And to make it even more weird, sometimes timeStamp will have the right date, and timeStampCopy will have the wrong date, and visa versa.</p>
  
  <pre><code>   public static Timestamp method(String date, DateFormat dateFormat) throws Exception {           
  
          // date is always "2017-02-17"     
  
          // original
          GregorianCalendar gCal = new GregorianCalendar();
          gCal.setTime(dateFormat.parse(date));
          Timestamp timeStamp = new Timestamp(gCal.getTimeInMillis());
  
          // copy
          GregorianCalendar gCalCopy= new GregorianCalendar();
          gCalCopy.setTime(dateFormat.parse(date));
          Timestamp timeStampCopy = new Timestamp(gCalCopy.getTimeInMillis());
  
          if (!timeStamp.toString().contains("2017-02-17"))
              System.out.println(timeStamp.toString());   
          if (!timeStampCopy.toString().contains("2017-02-17"))
              System.out.println(timeStampCopy.toString());   
  
          return timeStamp;
  
      }
  </code></pre>
  
  <p>I'm not sure what could be causing it but I tried this using a Date object and am having the same issues. I thought it could be a parsing issue but since it's doing the same thing twice I'm not sure.</p>
  
  <p>Below are some of the values that I'm getting:</p>
  
  <pre><code>timeStamp is:       2017-02-17 00:00:00.0
  timeStampCopy is:   1700-02-17 00:00:00.0
  </code></pre>