|
|
@ -1,6 +1,7 @@
|
|
|
|
package eu.dnetlib.ariadneplus.reader.utils;
|
|
|
|
package eu.dnetlib.ariadneplus.reader.utils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
|
|
import java.time.Year;
|
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@ -20,10 +21,7 @@ public class ESUtils {
|
|
|
|
.appendPattern(" yyyy")
|
|
|
|
.appendPattern(" yyyy")
|
|
|
|
.toFormatter(Locale.ROOT);
|
|
|
|
.toFormatter(Locale.ROOT);
|
|
|
|
private static DateTimeFormatter yearOnlyDateFormatter = new DateTimeFormatterBuilder()
|
|
|
|
private static DateTimeFormatter yearOnlyDateFormatter = new DateTimeFormatterBuilder()
|
|
|
|
.appendPattern("yyyy")
|
|
|
|
.appendPattern("yyyy").toFormatter();
|
|
|
|
.parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
|
|
|
|
|
|
|
|
.parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
|
|
|
|
|
|
|
|
.toFormatter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getESFormatDate(String originalDate) {
|
|
|
|
public static String getESFormatDate(String originalDate) {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
@ -31,22 +29,26 @@ public class ESUtils {
|
|
|
|
return parsedDate.format(elasticSearchDateFormatter);
|
|
|
|
return parsedDate.format(elasticSearchDateFormatter);
|
|
|
|
} catch(Exception e){
|
|
|
|
} catch(Exception e){
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
LocalDate parsedDate = LocalDate.parse(originalDate, originalRecordDateFormatter);
|
|
|
|
Year year = Year.parse(originalDate);
|
|
|
|
return parsedDate.format(elasticSearchDateFormatter);
|
|
|
|
return year.format(yearOnlyDateFormatter);
|
|
|
|
} catch (Exception e1) {
|
|
|
|
} catch (Exception e0) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
LocalDate parsedDate = LocalDate.parse(originalDate.substring(0, 10), elasticSearchDateFormatter);
|
|
|
|
LocalDate parsedDate = LocalDate.parse(originalDate, originalRecordDateFormatter);
|
|
|
|
return parsedDate.format(elasticSearchDateFormatter);
|
|
|
|
return parsedDate.format(elasticSearchDateFormatter);
|
|
|
|
} catch (Exception e2) {
|
|
|
|
} catch (Exception e1) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return parseBST(originalDate);
|
|
|
|
LocalDate parsedDate = LocalDate.parse(originalDate.substring(0, 10), elasticSearchDateFormatter);
|
|
|
|
} catch (Exception e3) {
|
|
|
|
return parsedDate.format(elasticSearchDateFormatter);
|
|
|
|
return "0000";
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return parseBST(originalDate);
|
|
|
|
|
|
|
|
} catch (Exception e3) {
|
|
|
|
|
|
|
|
return "0000";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static String parseBST(String BSTDate) {
|
|
|
|
private static String parseBST(String BSTDate) {
|
|
|
|