title: Parse date or datetime both as LocalDateTime in Java 8
body: <p>I need to parse a field which is sometimes given as a date and sometimes as a date/time. Is it possible to use single datatype for this using Java 8 time API?
  Currently, I attempted to use a LocalDateTime for it, but for following invocation <code>LocalDateTime.parse("1986-04-08", DateTimeFormatter.ofPattern("yyyy-MM-dd"))</code>
  I get a </p>
  
  <pre><code>java.time.DateTimeException: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 1986-04-08 of type java.time.format.Parsed
  </code></pre>
  
  <p>This is part of some generic parser accepting a date/datetime parse pattern as configuration option. So e.g. following solution with hardcoded parsing pattern</p>
  
  <pre><code>if ("yyyy-MM-dd".equals(pattern)) {
      LocalDate.parse(value, DateTimeFormatter.ofPattern("yyyy-MM-dd"))).atStartOfDay()
  }
  </code></pre>
  
  <p>is not an option for me.</p>
  
  <p>Any other suggestions how to code it in a clean way are welcome.</p>