title: XMLGregorianCalendar format date in ZonedDateTime
body: <p>I have a function which takes Date and gives XMLGregorianCalendar formatted date as below which returns date as <code>2017-11-30T00:00:00.000-08:00</code> when date provided as <code>2017-11-30</code></p>
  
  <pre><code>public static String xmlDate(Date date) {
      XMLGregorianCalendar xmlDate = null;
      if (date != null) {
          GregorianCalendar gc = new GregorianCalendar();
          Calendar cal = Calendar.getInstance();
          cal.setTime(date);
          gc.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
          gc.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
          gc.set(Calendar.MILLISECOND, 0);
  
          try {
              xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
          } catch (DatatypeConfigurationException e) {
              //exception
          }
      }
      return xmlDate.toString();
  }
  </code></pre>
  
  <p>I'm trying to rewrite above function with Java 8 ZonedDateTime but getting date as <code>2017-11-29T00:00:00-08:00</code> .How can I get the exact output same as the above function? Also I dont understand why the date is 29 instead of 30. </p>
  
  <pre><code>public static String zonedDatetime(Date date) {
      return ZonedDateTime.ofInstant(date.toInstant(), ZoneId.of("America/Los_Angeles"))
              .truncatedTo(ChronoUnit.DAYS)
              .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
  }
  </code></pre>