parse must succeed if the date is already in the expected format
This commit is contained in:
parent
1e3ff13aa4
commit
832b95f064
|
@ -15,12 +15,18 @@ public class ESUtils {
|
|||
.toFormatter();
|
||||
|
||||
public static String getESFormatDate(String originalDate) {
|
||||
try {
|
||||
LocalDate parsedDate = LocalDate.parse(originalDate, originalRecordDateFormatter);
|
||||
try{
|
||||
LocalDate parsedDate = LocalDate.parse(originalDate, elasticSearchDateFormatter);
|
||||
return parsedDate.format(elasticSearchDateFormatter);
|
||||
} catch (Exception e) {
|
||||
LocalDate parsedDate = LocalDate.parse(originalDate, yearOnlyDateFormatter);
|
||||
return parsedDate.format(yearOnlyDateFormatter);
|
||||
} catch(Exception e){
|
||||
try {
|
||||
LocalDate parsedDate = LocalDate.parse(originalDate, originalRecordDateFormatter);
|
||||
return parsedDate.format(elasticSearchDateFormatter);
|
||||
} catch (Exception e1) {
|
||||
LocalDate parsedDate = LocalDate.parse(originalDate, yearOnlyDateFormatter);
|
||||
return parsedDate.format(yearOnlyDateFormatter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue