title: Java 8: Convert file time (milliseconds from 1970) to RFC 1123 format
body: <p>This seems like it should be simple, but so far nothing I try is working. Basically I want to convert a file time in milliseconds from 1970 (the usual) to a TemporalAccessor and then to an <a href="https://www.rfc-editor.org/rfc/rfc1123" rel="nofollow noreferrer">RFC 1123</a> formatted string. However, while I can get examples that compile, I get runtime errors. For example:</p>
  <pre><code>// Just using 0 milliseconds time for quick and easy test
  System.out.println(java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format(
                  FileTime.from(0, TimeUnit.MILLISECONDS).toInstant()));
  </code></pre>
  <p>results in</p>
  <blockquote>
  <p>Exception in thread &quot;main&quot; java.time.temporal.UnsupportedTemporalTypeException:
  Unsupported field: DayOfMonth</p>
  </blockquote>
  <p>I have tried a few variations of this using different classes (Instant, LocalTime, Date), but I get the same result.</p>
  <p>What is the proper way to do this?</p>
  <p>UPDATE:
  The original question has been technically answered and I realized I needed to be more specific. I had already 'successfully' converted milliseconds to a TemporalAccessor myself, however it didn't seem like this object was in usable state.  I got a run time error when trying to use it to do what I really needed, which made me believe I hadn't created it properly. That something was missing. Either that or there is a bug in the RFC 1123 formatter.</p>
  <p>UPDATE 2:
  Thanks to Sleafar for posting a working answer.</p>
  <p>Using his example I did it slightly differently since for some reason I really wanted a 'complete' TemporalAccessor to do stuff with. Here is a working example:</p>
  <pre><code>TemporalAccessor time = ZonedDateTime.ofInstant(Instant.ofEpochMilli(0),
  ZoneId.systemDefault());
  System.out.println(
          java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format(time));
  </code></pre>