Revision 51254
Added by Alessia Bardi about 6 years ago
modules/dnet-oai-store-service/trunk/src/test/java/eu/dnetlib/data/oai/store/mongo/RecordInfoGeneratorTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.oai.store.mongo; |
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 |
import java.time.LocalDateTime; |
|
5 |
import java.time.ZoneId; |
|
6 |
import java.time.format.DateTimeFormatter; |
|
7 |
import java.util.Date; |
|
4 | 8 |
import java.util.zip.ZipEntry; |
5 | 9 |
import java.util.zip.ZipOutputStream; |
6 | 10 |
|
... | ... | |
43 | 47 |
System.out.println(record); |
44 | 48 |
} |
45 | 49 |
|
50 |
@Test |
|
51 |
public void parseDatestamp(){ |
|
52 |
String thedate = "2018-02-13T15:02:16.122Z"; |
|
53 |
//Because DateTimeFormatter.ISO_INSTANT does not work |
|
54 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); |
|
55 |
//DateTimeFormatter formatter = new DateTimeFormatterBuilder(DateTimeFormatter.ISO_INSTANT).appendInstant(3).toFormatter(); |
|
56 |
LocalDateTime d = LocalDateTime.parse(thedate, dtf); |
|
57 |
Date utilDate = Date.from(d.atZone(ZoneId.systemDefault()).toInstant()); |
|
58 |
} |
|
59 |
|
|
46 | 60 |
private Binary createCompressRecord(final String record) throws IOException { |
47 | 61 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
48 | 62 |
ZipOutputStream zos = new ZipOutputStream(os); |
Also available in: Unified diff
testing date parsing