1
|
package eu.dnetlib.data.mapreduce.hbase.broker.mapping;
|
2
|
|
3
|
import java.text.ParseException;
|
4
|
|
5
|
import org.apache.commons.lang3.time.DateUtils;
|
6
|
import org.apache.commons.logging.Log;
|
7
|
import org.apache.commons.logging.LogFactory;
|
8
|
|
9
|
public class DateParser {
|
10
|
|
11
|
private static final Log log = LogFactory.getLog(DateParser.class);
|
12
|
|
13
|
public static Long parse(final String s) {
|
14
|
if (s == null) {
|
15
|
log.warn("Date is NULL");
|
16
|
return null;
|
17
|
}
|
18
|
|
19
|
try {
|
20
|
return DateUtils.parseDate(s, "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss").getTime();
|
21
|
} catch (final ParseException e) {
|
22
|
log.warn("Invalid Date: " + s);
|
23
|
return null;
|
24
|
}
|
25
|
|
26
|
}
|
27
|
}
|