Corretta deserializzazione delle LocalDate in presenza dei dati di timezone
This commit is contained in:
@@ -1069,6 +1069,7 @@
|
||||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
<component name="WebServicesPlugin" addRequiredLibraries="true" />
|
||||
<component name="libraryTable">
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -140,7 +139,6 @@ public class UtilityString {
|
||||
|
||||
public static LocalDate parseLocalDate(String value) throws IOException {
|
||||
String format = determineDateFormat(value);
|
||||
|
||||
if (format == null) {
|
||||
try {
|
||||
return LocalDate.parse(value, DateTimeFormatter.ISO_DATE_TIME);
|
||||
@@ -150,6 +148,9 @@ public class UtilityString {
|
||||
|
||||
if (format == null)
|
||||
throw new IOException("Impossibile riconoscere il formato data per " + value);
|
||||
//A differenza di SimpleDateFormat il DateFormatter necessita di sapere se deve formattare la timezone (Es. 2024-03-22T16:00:00+01:00)
|
||||
if (format.equalsIgnoreCase("yyyy-MM-dd'T'HH:mm:ss") && value.length() > 19)
|
||||
format += "z";
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
@@ -230,7 +231,7 @@ public class UtilityString {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isIntNumber(String number){
|
||||
public static boolean isIntNumber(String number) {
|
||||
try {
|
||||
Integer.parseInt(number);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user