title: How to choose Date/Time class in java8 among LocalDateTime, ZonedDateTime and other classes?
body: <p>I want to convert pre Java8 like below.</p>
  
  <pre><code>DateFormat formatter = new SimpleDateFormat(timestampPattern, locale);
  Date dt = formatter.parse(timestamp);
  Date currentDateTime = getCurrentTime();
  </code></pre>
  
  <p>To Java 8 code to support more than 3 digits in milliseconds. I found ways to do that using the following simple code.</p>
  
  <pre><code>String parsedate="2016-03-16 01:14:21.6739";
  DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSS"); 
  LocalDateTime newdate = LocalDateTime.parse(parsedate, dateTimeFormatter);
  </code></pre>
  
  <p>Problem with above code is that you have to know specific class before parsing it like if it contains only date in you have to use LocalDate and if only time LocalTime and if date + time + zone you have to use ZonedDateTime.</p>
  
  <p>My problem is that I don't know timestampPattern or timestamp(Given in pre Java8 code snippet) before hand(as it is user input) hence can't choose subclass in my code. Is there any better way for this?</p>