public static long convertDateTimeToEpochMillis(String eventDate,String eventTime) {
String patternMills = "yyyy-MM-dd HH:mm:ss.SSS";
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
LocalDateTime localDateTime = LocalDateTime.parse(eventDate + " " +
eventTime, dtf);
}
This is giving a parsing exception when I am passing 2018-07-19 23:11:52.3
but parses successfully for 2018-07-19 23:11:52.312
. I don't want to specify 3 different patterns for different times like yyyy-MM-dd HH:mm:ss.S
,yyyy-MM-dd HH:mm:ss.SS
and yyyy-MM-dd HH:mm:ss.SSS
.
Can I provide a single pattern which will take up to 1/10th of a sec, 100th of a sec and millisec?