Coverting String to LocalTime with/without nanoOfSeconds
问题 I need to convert a string to LocalTime (java-8 not joda) that may or maynot have nanoOfSeconds in the string. The String format is in the form of 07:06:05 or 07:06:05.123456 The string may or may not have a decimal place in the seconds and when it does there could be any number of characters to represent the Nano Seconds part. Using a DateTimeForamtter such as DateTimeFormatter dtf = DateTimeFormatter.ofPattern("H:mm:ss"); or DateTimeFormatter dtf = DateTimeFormatter.ofPattern("H:mm:ss