title: how to find seconds since 1970 in java
body: <p>iam working with a real time project where i got a requirement to find seconds since 1970 january 1.I have used the following code to find out seconds but is giving wrong result.The code is as follows.</p>
  
  <pre><code>public long returnSeconds(int year, int month, int date) {
      Calendar calendar1 = Calendar.getInstance();
      Calendar calendar2 = Calendar.getInstance();
      calendar1.set(1970, 01, 01);
      calendar2.set(year, month, date);
      long milliseconds1 = calendar1.getTimeInMillis();
      long milliseconds2 = calendar2.getTimeInMillis();
      long diff = milliseconds2 - milliseconds1;
      long seconds = diff / 1000;
      return seconds;
  }
  </code></pre>
  
  <p>In the above in place of <code>year,month,date</code> I'm passing <code>2011,10,1</code> and iam getting </p>
  
  <pre><code>1317510000
  </code></pre>
  
  <p>but the correct answer is </p>
  
  <pre><code>1317427200
  </code></pre>
  
  <p>Any help regarding this is very useful to me.</p>