use of localdatetime in deprecated classes
This commit is contained in:
parent
ce55185bcf
commit
840e83aada
|
@ -33,8 +33,11 @@ import static eu.dnetlib.openaire.community.CommunityConstants.PIPE_SEPARATOR;
|
|||
import static eu.dnetlib.openaire.community.CommunityConstants.PROJECTS_ID_SUFFIX;
|
||||
import static eu.dnetlib.openaire.community.CommunityConstants.ZENODOCOMMUNITY_ID_SUFFIX;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -71,8 +74,8 @@ public class CommunityMappingUtils {
|
|||
|
||||
summary.setId(c.getId());
|
||||
summary.setShortName(c.getLabel());
|
||||
// summary.setLastUpdateDate(c.getLastUpdateDate());
|
||||
// summary.setCreationDate(c.getCreationDate());
|
||||
summary.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
||||
summary.setCreationDate(convertToLocalDateTime(c.getCreationDate()));
|
||||
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getLabel());
|
||||
summary.setType(c.getType());
|
||||
|
||||
|
@ -99,7 +102,7 @@ public class CommunityMappingUtils {
|
|||
public static CommunityDetails asCommunityProfile(final Context c) {
|
||||
|
||||
final CommunityDetails p = new CommunityDetails(asCommunitySummary(c));
|
||||
// p.setLastUpdateDate(c.getLastUpdateDate());
|
||||
p.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
||||
final Map<String, List<Param>> params = c.getParams();
|
||||
if (params.containsKey(CPROFILE_SUBJECT)) {
|
||||
p.setSubjects(splitValues(asValues(params.get(CPROFILE_SUBJECT)), CSV_DELIMITER));
|
||||
|
@ -116,11 +119,12 @@ public class CommunityMappingUtils {
|
|||
|
||||
}
|
||||
if (params.containsKey(CPROFILE_CREATIONDATE)) {
|
||||
// try {
|
||||
// p.setCreationDate(org.apache.commons.lang3.time.DateUtils.parseDate(asCsv(params.get(CPROFILE_CREATIONDATE)), pattern));
|
||||
// } catch (final ParseException e) {
|
||||
// log.debug("Exception on date format: " + e.getMessage());
|
||||
// }
|
||||
try {
|
||||
final Date d = org.apache.commons.lang3.time.DateUtils.parseDate(asCsv(params.get(CPROFILE_CREATIONDATE)), pattern);
|
||||
p.setCreationDate(convertToLocalDateTime(d));
|
||||
} catch (final Exception e) {
|
||||
log.debug("Exception on date format: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
|
@ -272,4 +276,10 @@ public class CommunityMappingUtils {
|
|||
return String.format("<param name='%s'>%s</param>\n", paramName, value);
|
||||
}
|
||||
|
||||
private static LocalDateTime convertToLocalDateTime(final Date date) {
|
||||
return date.toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue