Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -25,26 +25,7 @@ public class UtilityString {
|
||||
|
||||
//private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
private static final Map<String, String> DATE_FORMAT_REGEXPS = new HashMap<String, String>() {{
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//giorno-mese-giorno
|
||||
put("^\\d{1,2}/\\d{1,2}/\\d{4}$", "dd/MM/yyyy");
|
||||
put("^\\d{1,2}\\.\\d{1,2}\\.\\d{4}$", "dd.MM.yyyy");
|
||||
put("^\\d{1,2}-\\d{1,2}-\\d{4}$", "dd-MM-yyyy");
|
||||
|
||||
//anno-mese-giorno
|
||||
put("^\\d{4}/\\d{1,2}/\\d{1,2}$", "yyyy/MM/dd");
|
||||
put("^\\d{4}\\.\\d{1,2}\\.\\d{1,2}$", "yyyy.MM.dd");
|
||||
put("^\\d{4}-\\d{1,2}-\\d{1,2}$", "yyyy-MM-dd");
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//senza spazi
|
||||
put("^\\d{8}$", "yyyyMMdd");
|
||||
put("^\\d{6}$", "yyMMdd");
|
||||
put("^\\d{1,2}\\s[a-z]{3}\\s\\d{4}$", "dd MMM yyyy");
|
||||
put("^\\d{1,2}\\s[a-z]{4,}\\s\\d{4}$", "dd MMMM yyyy");
|
||||
private static final Map<String, String> DATETIME_FORMAT_REGEXPS = new HashMap<String, String>() {{
|
||||
|
||||
put("^\\d{12}$", "yyyyMMddHHmm");
|
||||
put("^\\d{8}\\s\\d{4}$", "yyyyMMdd HHmm");
|
||||
@@ -110,6 +91,29 @@ public class UtilityString {
|
||||
put("^(\\d{4})-(\\d{2})-(\\d{2})t(\\d{2}):(\\d{2}):(\\d{2})((\\+|-)(\\d{2}):(\\d{2}))$", "yyyy-MM-dd'T'HH:mm:ss");
|
||||
}};
|
||||
|
||||
private static final Map<String, String> DATE_FORMAT_REGEXPS = new HashMap<String, String>() {{
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//giorno-mese-giorno
|
||||
put("^\\d{1,2}/\\d{1,2}/\\d{4}$", "dd/MM/yyyy");
|
||||
put("^\\d{1,2}\\.\\d{1,2}\\.\\d{4}$", "dd.MM.yyyy");
|
||||
put("^\\d{1,2}-\\d{1,2}-\\d{4}$", "dd-MM-yyyy");
|
||||
|
||||
//anno-mese-giorno
|
||||
put("^\\d{4}/\\d{1,2}/\\d{1,2}$", "yyyy/MM/dd");
|
||||
put("^\\d{4}\\.\\d{1,2}\\.\\d{1,2}$", "yyyy.MM.dd");
|
||||
put("^\\d{4}-\\d{1,2}-\\d{1,2}$", "yyyy-MM-dd");
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
//senza spazi
|
||||
put("^\\d{8}$", "yyyyMMdd");
|
||||
put("^\\d{6}$", "yyMMdd");
|
||||
put("^\\d{1,2}\\s[a-z]{3}\\s\\d{4}$", "dd MMM yyyy");
|
||||
put("^\\d{1,2}\\s[a-z]{4,}\\s\\d{4}$", "dd MMMM yyyy");
|
||||
|
||||
}};
|
||||
|
||||
private static final Map<String, String> TIME_FORMAT_REGEXPS = new HashMap<String, String>() {{
|
||||
put("^\\d{1,2}:\\d{2}$", "HH:mm");
|
||||
put("^\\d{2}:\\d{2}$", "HH:mm");
|
||||
@@ -123,6 +127,11 @@ public class UtilityString {
|
||||
return DATE_FORMAT_REGEXPS.get(regexp);
|
||||
}
|
||||
}
|
||||
for (String regexp : DATETIME_FORMAT_REGEXPS.keySet()) {
|
||||
if (timeString.toLowerCase().matches(regexp)) {
|
||||
return DATETIME_FORMAT_REGEXPS.get(regexp);
|
||||
}
|
||||
}
|
||||
return null; // Unknown format.
|
||||
}
|
||||
|
||||
@@ -209,8 +218,15 @@ public class UtilityString {
|
||||
|
||||
if (format == null)
|
||||
throw new IOException("Impossibile riconoscere il formato data per " + value);
|
||||
|
||||
if (format.equalsIgnoreCase("yyyy-MM-dd'T'HH:mm:ss") && value.length() > 19)
|
||||
format += "z";
|
||||
|
||||
else if (DATE_FORMAT_REGEXPS.containsValue(format)) {
|
||||
final LocalDate localDate = parseLocalDate(value, format);
|
||||
return localDate.atStartOfDay();
|
||||
}
|
||||
|
||||
return parseLocalDateTime(value, format);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user