[BIOLEVANTE]
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
- risolto problema in Mapping di valori null in LocalDateTime
This commit is contained in:
@@ -217,7 +217,15 @@ public class SqlFieldHolder {
|
||||
} else if (dtoType.equals(LocalDate.class)) {
|
||||
converter = data -> {
|
||||
try {
|
||||
return UtilityString.parseLocalDate(data.toString());
|
||||
return UtilityLocalDate.localDateFromDate((Date) data);
|
||||
} catch (Exception e) {
|
||||
return data;
|
||||
}
|
||||
};
|
||||
} else if (dtoType.equals(LocalDateTime.class)) {
|
||||
converter = data -> {
|
||||
try {
|
||||
return UtilityLocalDate.localDateTimeFromDate((Date) data);
|
||||
} catch (Exception e) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,12 @@ import it.integry.ems_model.config.EmsRestConstants;
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.time.temporal.TemporalField;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -112,6 +115,13 @@ public class UtilityLocalDate {
|
||||
.atStartOfDay();
|
||||
}
|
||||
|
||||
public static LocalDate localDateFromLocalDateTime(LocalDateTime dateToConvert) {
|
||||
if (dateToConvert == null) return null;
|
||||
|
||||
return dateToConvert
|
||||
.toLocalDate();
|
||||
}
|
||||
|
||||
public static LocalDate timeToLocalDate(long time, @Nullable String timezone) {
|
||||
return Instant.ofEpochSecond(time)
|
||||
.atZone(timezone == null ? currentZone : ZoneId.of(timezone))
|
||||
@@ -263,4 +273,8 @@ public class UtilityLocalDate {
|
||||
//Conversione in minuti
|
||||
return diffInSeconds.divide(BigDecimal.valueOf(60), 6, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
public static long getTimestamp(LocalDate date) {
|
||||
return date.atStartOfDay(currentZone).toEpochSecond();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user