Revision 52078
Added by Alessia Bardi almost 6 years ago
RecordInfoGeneratorTest.java | ||
---|---|---|
17 | 17 |
import org.junit.Test; |
18 | 18 |
import org.springframework.core.io.ClassPathResource; |
19 | 19 |
|
20 |
import static java.time.format.DateTimeFormatter.ofPattern; |
|
21 |
|
|
20 | 22 |
/** |
21 | 23 |
* RecordInfoGenerator Tester. |
22 | 24 |
* |
... | ... | |
52 | 54 |
public void parseDatestamp(){ |
53 | 55 |
String thedate = "2018-02-13T15:02:16.122Z"; |
54 | 56 |
//Because DateTimeFormatter.ISO_INSTANT does not work |
55 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX");
|
|
57 |
DateTimeFormatter dtf = ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); |
|
56 | 58 |
//DateTimeFormatter formatter = new DateTimeFormatterBuilder(DateTimeFormatter.ISO_INSTANT).appendInstant(3).toFormatter(); |
57 | 59 |
LocalDateTime d = LocalDateTime.parse(thedate, dtf); |
58 | 60 |
Date utilDate = Date.from(d.atZone(ZoneId.systemDefault()).toInstant()); |
... | ... | |
72 | 74 |
String theDate = "2018-02-13T15:02:16.122Z"; |
73 | 75 |
// org.apache.commons.lang.time.DateUtils.parseDate( |
74 | 76 |
// theDate, |
75 |
// new String[]{ "yyyy-MM-dd'T'HH:mm:ss.SX" }); |
|
77 |
// new String[]{ "yyyy-MM-dd'T'HH:mm:ss.SSSX" });
|
|
76 | 78 |
gen.parseDate(theDate); |
77 | 79 |
} |
78 | 80 |
|
79 | 81 |
|
82 |
@Test |
|
83 |
public void parseDatestamp3() throws ParseException { |
|
84 |
String theDate = "2017-12-12T17:06:28.537+01:00"; |
|
85 |
// LocalDateTime d = LocalDateTime.parse(theDate, DateTimeFormatter.ISO_ZONED_DATE_TIME); |
|
86 |
// Date utilDate = Date.from(d.atZone(ZoneId.systemDefault()).toInstant()); |
|
87 |
gen.parseDate(theDate); |
|
88 |
} |
|
80 | 89 |
|
90 |
|
|
81 | 91 |
private Binary createCompressRecord(final String record) throws IOException { |
82 | 92 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
83 | 93 |
ZipOutputStream zos = new ZipOutputStream(os); |
Also available in: Unified diff
We also have some date as ISO DateTime with Zone...