Project

General

Profile

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