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();
|
.toFormatter();
|
||||||
|
|
||||||
public static String getESFormatDate(String originalDate) {
|
public static String getESFormatDate(String originalDate) {
|
||||||
try {
|
try{
|
||||||
LocalDate parsedDate = LocalDate.parse(originalDate, originalRecordDateFormatter);
|
LocalDate parsedDate = LocalDate.parse(originalDate, elasticSearchDateFormatter);
|
||||||
return parsedDate.format(elasticSearchDateFormatter);
|
return parsedDate.format(elasticSearchDateFormatter);
|
||||||
} catch (Exception e) {
|
} catch(Exception e){
|
||||||
LocalDate parsedDate = LocalDate.parse(originalDate, yearOnlyDateFormatter);
|
try {
|
||||||
return parsedDate.format(yearOnlyDateFormatter);
|
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