dbf-export это uNIX time!
This commit is contained in:
parent
f6a60c023c
commit
f85baa9800
3 changed files with 2 additions and 40 deletions
|
|
@ -50,12 +50,6 @@
|
||||||
<artifactId>classes</artifactId>
|
<artifactId>classes</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TEST -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.testng</groupId>
|
|
||||||
<artifactId>testng</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,6 @@ import com.linuxense.javadbf.DBFField;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf08;
|
import ru.clearing.classes.statics.data.sdf.SDf08;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -18,7 +15,7 @@ public class S_DF08_Converter extends DFConverter<SDf08> {
|
||||||
public Object[] toObjectArray(SDf08 entity) {
|
public Object[] toObjectArray(SDf08 entity) {
|
||||||
List<Object> values = new LinkedList<>();
|
List<Object> values = new LinkedList<>();
|
||||||
values.add(convertStrToLong(entity.getNumber()));
|
values.add(convertStrToLong(entity.getNumber()));
|
||||||
values.add(typeMatch(convertStrToDate(entity.getDatetime())));
|
values.add(typeMatch(convertStrToLong(entity.getDatetime()))); // UNIX TIME
|
||||||
return values.toArray(Object[]::new);
|
return values.toArray(Object[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,7 +23,7 @@ public class S_DF08_Converter extends DFConverter<SDf08> {
|
||||||
public DBFField[] getDBFHeaders() {
|
public DBFField[] getDBFHeaders() {
|
||||||
List<DBFField> dbfFields = new LinkedList<>();
|
List<DBFField> dbfFields = new LinkedList<>();
|
||||||
dbfFields.add(new DBFField("NUMBER", DBFDataType.NUMERIC, 10));
|
dbfFields.add(new DBFField("NUMBER", DBFDataType.NUMERIC, 10));
|
||||||
dbfFields.add(new DBFField("DATETIME", DBFDataType.DATE));
|
dbfFields.add(new DBFField("DATETIME", DBFDataType.NUMERIC, 13)); // UNIX TIME
|
||||||
return dbfFields.toArray(DBFField[]::new);
|
return dbfFields.toArray(DBFField[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,12 +35,4 @@ public class S_DF08_Converter extends DFConverter<SDf08> {
|
||||||
private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||||
private static final DateTimeFormatter DATE_TIME_FMT = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss");
|
private static final DateTimeFormatter DATE_TIME_FMT = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss");
|
||||||
|
|
||||||
Object convertStrToDate(String s) {
|
|
||||||
if (s == null) return null;
|
|
||||||
if (s.matches("\\d{2}.\\d{2}.\\d{4}")) {
|
|
||||||
return LocalDate.parse(s, DATE_FMT).atStartOfDay(ZoneId.systemDefault()).toInstant();
|
|
||||||
} else {
|
|
||||||
return LocalDateTime.parse(s, DATE_TIME_FMT).atZone(ZoneId.systemDefault()).toInstant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package ru.spcex.clearing.dbf.exporter.services.converters;
|
|
||||||
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
public class S_DF08_ConverterTest {
|
|
||||||
@Test
|
|
||||||
public void testTestConvertStrToLong() {
|
|
||||||
S_DF08_Converter converter = new S_DF08_Converter();
|
|
||||||
Assert.assertNull(converter.convertStrToLong(null));
|
|
||||||
Assert.assertEquals(1L, converter.convertStrToLong("1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTestConvertStrToDate() {
|
|
||||||
S_DF08_Converter converter = new S_DF08_Converter();
|
|
||||||
Assert.assertNull(converter.convertStrToDate(null));
|
|
||||||
Assert.assertEquals("2022-12-29 00:00:00.0", converter.convertStrToDate("29.12.2022").toString());
|
|
||||||
Assert.assertEquals("2023-01-13 15:32:01.0", converter.convertStrToDate("13.01.2023 15:32:01").toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue