Revision 51253
Added by Alessia Bardi about 6 years ago
modules/dnet-oai-store-service/trunk/src/main/java/eu/dnetlib/data/oai/store/mongo/RecordInfoGenerator.java | ||
---|---|---|
39 | 39 |
@Resource |
40 | 40 |
private ProvenanceExtractor provenanceExtractor; |
41 | 41 |
|
42 |
private DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); |
|
43 |
|
|
42 | 44 |
@SuppressWarnings("unchecked") |
43 | 45 |
public RecordInfo transformDBObject(final DBObject object, final boolean includeBody) { |
44 | 46 |
if ((object == null) || object.keySet().isEmpty()) return null; |
... | ... | |
57 | 59 |
//assuming we have a string in the form 2017-12-05T14:24:48.61Z to convert to Date |
58 | 60 |
log.debug("Why the hell there are string instead of Dates in datestamp???"); |
59 | 61 |
try { |
60 |
LocalDateTime d = LocalDateTime.parse(datestampObject.toString(), DateTimeFormatter.ISO_INSTANT);
|
|
62 |
LocalDateTime d = LocalDateTime.parse(datestampObject.toString(), dtf);
|
|
61 | 63 |
Date utilDate = Date.from(d.atZone(ZoneId.systemDefault()).toInstant()); |
62 | 64 |
record.setDatestamp(utilDate); |
63 | 65 |
}catch(Exception dateException){ |
Also available in: Unified diff
Using custom datetimeformatter that can parse milliseconds