|
|
|
@ -15,6 +15,7 @@ import org.apache.commons.codec.binary.Hex;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
|
|
|
|
|
import com.github.sisyphsu.dateparser.DateParserUtils;
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.*;
|
|
|
|
@ -305,13 +306,7 @@ public class ModelSupport {
|
|
|
|
|
|
|
|
|
|
private static final String schemeTemplate = "dnet:%s_%s_relations";
|
|
|
|
|
|
|
|
|
|
public static final String[] DATE_TIME_FORMATS = {
|
|
|
|
|
"yyyy-MM-dd'T'hh:mm:ss.SSS'Z'",
|
|
|
|
|
"yyyy-MM-dd'T'hh:mm:ss'Z'",
|
|
|
|
|
"yyyy-MM-dd hh:mm:ss'Z'",
|
|
|
|
|
"yyyy-MM-dd hh:mm:ss",
|
|
|
|
|
"yyyy-MM-dd"
|
|
|
|
|
};
|
|
|
|
|
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
|
|
|
|
|
|
|
|
|
private ModelSupport() {
|
|
|
|
|
}
|
|
|
|
@ -506,8 +501,8 @@ public class ModelSupport {
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(dateA) && StringUtils.isNotBlank(dateB)) {
|
|
|
|
|
|
|
|
|
|
final Date a = tryParse(dateA);
|
|
|
|
|
final Date b = tryParse(dateB);
|
|
|
|
|
final Date a = DateParserUtils.parseDate(dateA);
|
|
|
|
|
final Date b = DateParserUtils.parseDate(dateB);
|
|
|
|
|
|
|
|
|
|
if (Objects.nonNull(a) && Objects.nonNull(b)) {
|
|
|
|
|
return a.before(b) ? dateA : dateB;
|
|
|
|
@ -519,14 +514,4 @@ public class ModelSupport {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Date tryParse(String date) throws DateTimeParseException {
|
|
|
|
|
try {
|
|
|
|
|
return DateUtils.parseDate(date, DATE_TIME_FORMATS);
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
// ignore it, try another format
|
|
|
|
|
}
|
|
|
|
|
final String formats = String.join("\n", Arrays.asList(DATE_TIME_FORMATS));
|
|
|
|
|
throw new DateTimeParseException(String.format("cannot parse %s, supported formats: \n%s", date, formats), date, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|