Revision 50157
Added by Alessia Bardi over 6 years ago
modules/dnet-mapreduce-jobs/trunk/src/test/java/eu/dnetlib/data/mapreduce/hbase/oai/OAIFeedMapperTest.java | ||
---|---|---|
14 | 14 |
import eu.dnetlib.data.mapreduce.hbase.oai.config.OAIConfigurationStringReader; |
15 | 15 |
import eu.dnetlib.data.mapreduce.hbase.oai.utils.MongoSetCollection; |
16 | 16 |
import eu.dnetlib.data.mapreduce.hbase.oai.utils.RecordFieldsExtractor; |
17 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
18 | 17 |
import org.apache.commons.io.IOUtils; |
19 | 18 |
import org.apache.hadoop.mapreduce.Counter; |
20 | 19 |
import org.dom4j.DocumentException; |
... | ... | |
69 | 68 |
|
70 | 69 |
oaiConfiguration = oaiConfigurationReader.getOaiConfiguration(); |
71 | 70 |
|
72 |
String feedDateString = DateUtils.now_ISO8601(); |
|
71 |
//String feedDateString = DateUtils.now_ISO8601(); |
|
72 |
String feedDateString = "2017-12-18T12:00:04+00:00"; |
|
73 | 73 |
try { |
74 | 74 |
feedDate = org.apache.commons.lang.time.DateUtils.parseDate( |
75 | 75 |
feedDateString, |
modules/dnet-mapreduce-jobs/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/oai/OaiFeedMapper.java | ||
---|---|---|
30 | 30 |
import eu.dnetlib.miscutils.functional.xml.IndentXmlString; |
31 | 31 |
import org.apache.commons.io.output.ByteArrayOutputStream; |
32 | 32 |
import org.apache.commons.lang.StringUtils; |
33 |
import org.apache.commons.lang.time.DateUtils; |
|
34 | 33 |
import org.apache.hadoop.io.NullWritable; |
35 | 34 |
import org.apache.hadoop.io.Text; |
36 | 35 |
import org.apache.hadoop.mapreduce.Mapper; |
... | ... | |
114 | 113 |
|
115 | 114 |
String feedDateString = context.getConfiguration().get(JobParams.OAI_FEED_DATE); |
116 | 115 |
try { |
117 |
feedDate = DateUtils.parseDate(feedDateString, new String[]{"yyyy-MM-dd\'T\'hh:mm:ss\'Z\'"}); |
|
116 |
// date will be in the form: 2017-12-18T12:00:04+00:00 |
|
117 |
feedDate = org.apache.commons.lang.time.DateUtils.parseDate( |
|
118 |
feedDateString, |
|
119 |
new String[]{ "yyyy-MM-dd'T'HH:mm:ssXXX", "yyyy-MM-dd'T'HH:mm:ssZ" }); |
|
118 | 120 |
} catch (ParseException e) { |
119 | 121 |
e.printStackTrace(System.err); |
120 | 122 |
throw new RuntimeException(e); |
Also available in: Unified diff
Fixed date parsing in OAI