title: JSR 310 :: System.currentTimeMillis() vs Instant.toEpochMilli() :: TimeZone
body: <p>Could you please shed some light on how to obtain correct epoch time in milliseconds for a default system timezone and given timezone.</p>
  
  <h3>Given</h3>
  
  <p>1. TimeZone: GMT+3</p>
  
  <p>2. The following code snippet:</p>
  
  <pre><code>import java.time.*;
  
  public class Main {        
      public static void main(String[] args) {
          System.out.println(LocalDateTime
              .now()
              .atZone(ZoneOffset.UTC)
              .toInstant()
              .toEpochMilli()
          );
          System.out.println(LocalDateTime
              .now()
              .atZone(ZoneOffset.of("+3"))
              .toInstant()
              .toEpochMilli()
          );
          System.out.println(System.currentTimeMillis());
      }
  }
  </code></pre>
  
  <p>3. Output:</p>
  
  <pre><code>1444158955508
  1444148155508
  1444148155508
  </code></pre>
  
  <p>4. JavaDoc for <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#currentTimeMillis%28%29" rel="noreferrer">System.currentTimeMillis()</a> that tells that returned value will be <em>the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.</em></p>
  
  <h3>So, why</h3>
  
  <ol>
  <li>the output of the <code>LocalDateTime</code> at <code>GMT+3</code> is the same as of <code>System.currentTimeMillis()</code>, although the docs for the <code>System.currentTimeMillis()</code> mention <code>UTC</code>?</li>
  <li>the output of the <code>LocalDateTime</code> at <code>UTC</code> differs from <code>System.currentTimeMillis()</code>, although the docs for the <code>System.currentTimeMillis()</code> mention <code>UTC</code>?</li>
  </ol>