title: Converting LocalDateTime Object to LocalDateTime
body: <p>I am new to Java and I am working on Java 8.</p>
  <p>I am trying to convert LocalDateTime Object to LocalDateTime but not able to find any way without converting it to String. Is there any direct method for converting Object to LocalDateTime when the underlying Object type is LocalDateTime?</p>
  <p>Moreover, if there is any way to convert, can it work for underlying String type LocalDateTime Object too?</p>
  <p>Below is my current code which is converting the Object to String before converting it to LocalDateTime as LocalDateTime.parse method needs String input.</p>
  <pre><code>public static LocalDateTime toDateTime(Object dateTimeObject) {
      LocalDateTime dateTime = LocalDateTime.parse(dateTimeObject.toString(), DateTimeFormatter.ofPattern(&quot;yyyy-MM-dd'T'HH:mm:ss&quot;));
      
      return dateTime;
  }
  </code></pre>