title: How to format a ZonedDateTime to a String?
body: <p>I want to convert a <code>ZonedDateTime</code> to a <code>String</code> in the format of <code>(&quot;dd/MM/yyyy - hh:mm&quot;)</code>. I know this is possible in Joda-Time other types, just using their <code>toString(&quot;dd/MM/yyyy - hh:mm&quot;)</code>....But this doesn't work with <code>ZonedDateTime.toString()</code>.</p>
  <h1><strong>How can I format a <code>ZonedDateTime</code> to a <code>String</code>?</strong></h1>
  <hr />
  <p>EDIT:</p>
  <p>I tried to print the time in another timezone and the result appears to be the same always:</p>
  <pre><code>ZonedDateTime date = ZonedDateTime.now();
  ZoneId la = ZoneId.of(&quot;America/Los_Angeles&quot;);
  ZonedDateTime date2 = date.of(date.toLocalDateTime(), la);
  
  // 24/02/2017 - 04:53
  System.out.println(DateTimeFormatter.ofPattern(&quot;dd/MM/yyyy - hh:mm&quot;).format(date));
  // same result as the previous one
  // 24/02/2017 - 04:53
  System.out.println(DateTimeFormatter.ofPattern(&quot;dd/MM/yyyy - hh:mm&quot;).format(date2));
  </code></pre>
  <p>And I am not in the same timezone as Los Angeles.</p>
  <hr />
  <p>EDIT 2:</p>
  <p>Found how to change the timezones:</p>
  <pre><code>// Change this:
  ZonedDateTime date2 = date.of(date.toLocalDateTime(), la); // incorrect!
  // To this:
  ZonedDateTime date2 = date.withZoneSameInstant(la);
  </code></pre>