I have many formats of inputs coming for DateTime column which includes 1."MM/dd/yyyy HH:mm:ss a" 2."MM/dd/yyyy HH:mm:ss" 3."MM/dd/yyyy HH:mm" 4."yyyyMMdd"
This should be formatted and giving me a output of the longest format which is 1."MM/dd/yyyy HH:mm:ss a" filling in the remaining format with either 00 values if doesn't exist.
This is what I am trying:
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(""
+ "[MM/dd/yyyy HH:mm:ss a]"
+ "[MM/dd/yyyy HH:mm:ss]"
+ "[MM/dd/yyyy HH:mm]"
+ "[yyyyMMdd]");
return
me.setManufacturingDate(LocalDateTime.parse(mm.getManufacturingDate().toString(),
dateFormatter));
Please do recommend a different way of method if I am heading wrong or fix this problem for me. Thanks in advance and any help will be much appreciated.