Revision 55311
Added by Alessia Bardi about 5 years ago
modules/dnet-collector-plugins/trunk/src/main/java/eu/dnetlib/data/collector/plugins/datacite/DataciteCollectorPlugin.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.collector.plugins.datacite; |
2 | 2 |
|
3 |
import java.util.Date; |
|
3 |
import java.time.LocalDateTime; |
|
4 |
import java.time.ZoneId; |
|
5 |
import java.time.format.DateTimeFormatter; |
|
4 | 6 |
|
5 | 7 |
import eu.dnetlib.data.collector.plugin.AbstractCollectorPlugin; |
6 | 8 |
import eu.dnetlib.data.collector.plugin.CollectorPlugin; |
7 | 9 |
import eu.dnetlib.data.collector.rmi.CollectorServiceException; |
8 | 10 |
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor; |
9 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
10 | 11 |
import org.apache.commons.lang3.StringUtils; |
11 | 12 |
import org.apache.commons.logging.Log; |
12 | 13 |
import org.apache.commons.logging.LogFactory; |
... | ... | |
15 | 16 |
|
16 | 17 |
private static final Log log = LogFactory.getLog(DataciteCollectorPlugin.class); |
17 | 18 |
|
19 |
private DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
20 |
|
|
18 | 21 |
@Override |
19 | 22 |
public Iterable<String> collect(InterfaceDescriptor interfaceDescriptor, String fromDate, String untilDate) throws CollectorServiceException { |
20 | 23 |
|
... | ... | |
22 | 25 |
if(StringUtils.isBlank(baseurl)) throw new CollectorServiceException("baseUrl cannot be empty"); |
23 | 26 |
long timestamp= 0; |
24 | 27 |
if (StringUtils.isNotBlank(fromDate)) { |
25 |
Date parsed = new DateUtils().parse(fromDate);
|
|
26 |
timestamp =parsed.getTime() /1000;
|
|
27 |
log.debug("Querying for Datacite records from timestamp "+timestamp+" (date was "+fromDate+")");
|
|
28 |
LocalDateTime d = LocalDateTime.parse(fromDate, dtf);
|
|
29 |
timestamp = d.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
30 |
log.info("Querying for Datacite records from timestamp "+timestamp+" (date was "+fromDate+")");
|
|
28 | 31 |
} |
29 | 32 |
|
30 | 33 |
final long finalTimestamp = timestamp; |
Also available in: Unified diff
Fixing date parsing on DataciteCollector Plugin