title: String of date to OffsetDateTime
body: <p>I am converting string of date/datetime to <code>OffsetDateTime</code> and I have  datetime format which may have one of these values</p>
  
  <pre><code>yyyy-MM-dd, yyyy/MM/dd
  </code></pre>
  
  <p>Sometimes with and without time and I need to convert this into <code>OffsetDateTime</code>.</p>
  
  <p>I have tried below code</p>
  
  <pre><code>// for format yyyy-MM-dd
  DateTimeFormatter DATE_FORMAT = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd")
                          .parseDefaulting(ChronoField.HOUR_OF_DAY, 0)
                          .parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0)
                          .parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)
                          .parseDefaulting(ChronoField.MILLI_OF_SECOND, 0)
                          .toFormatter();
  </code></pre>
  
  <p>As it doesn't have time I am setting this to default values but when I try to parse</p>
  
  <pre><code>OffsetDateTime.parse("2016-06-06", DATE_FORMAT)
  </code></pre>
  
  <p>It is throwing error like </p>
  
  <blockquote>
    <p>Exception in thread "main" java.time.format.DateTimeParseException: Text '2016-06-06' could not be parsed: Unable to obtain OffsetDateTime from TemporalAccessor: {},ISO resolved to 2016-06-06T00:00 of type java.time.format.Parsed</p>
  </blockquote>
  
  <p>Can anyone help me how to solve this?</p>