| Line 31... |
Line 31... |
| 31 |
private static final DateTimeFormatter SHORT_MONTH_DATE_YEAR_FORMATTER = DateTimeFormatter.ofPattern("dd-MMM-yy");
|
31 |
private static final DateTimeFormatter SHORT_MONTH_DATE_YEAR_FORMATTER = DateTimeFormatter.ofPattern("dd-MMM-yy");
|
| 32 |
private StringUtils(){
|
32 |
private StringUtils(){
|
| 33 |
|
33 |
|
| 34 |
}
|
34 |
}
|
| 35 |
|
35 |
|
| - |
|
36 |
private static final Pattern WHITESPACE_RUN = Pattern.compile("[\\s\\u00A0\\u1680\\u2000-\\u200B\\u202F\\u205F\\u3000\\uFEFF]+");
|
| - |
|
37 |
|
| - |
|
38 |
/**
|
| - |
|
39 |
* Normalizes whitespace: replaces every run of whitespace-like characters
|
| - |
|
40 |
* (spaces, tabs, CR/LF, non-breaking space , other Unicode spaces and
|
| - |
|
41 |
* zero-width characters) with a single regular space, then trims. Non-whitespace
|
| - |
|
42 |
* symbols (e.g. the degree sign) are preserved. Null-safe.
|
| - |
|
43 |
*/
|
| - |
|
44 |
public static String normalizeWhitespace(String value) {
|
| - |
|
45 |
if (value == null) {
|
| - |
|
46 |
return null;
|
| - |
|
47 |
}
|
| - |
|
48 |
return WHITESPACE_RUN.matcher(value).replaceAll(" ").trim();
|
| - |
|
49 |
}
|
| - |
|
50 |
|
| 36 |
public static final LocalDate fromShortMonthDateYear(String dateString) throws DateTimeParseException {
|
51 |
public static final LocalDate fromShortMonthDateYear(String dateString) throws DateTimeParseException {
|
| 37 |
dateString = dateString.toLowerCase();
|
52 |
dateString = dateString.toLowerCase();
|
| 38 |
dateString = StringUtils.capitalizeFirstChar(dateString);
|
53 |
dateString = StringUtils.capitalizeFirstChar(dateString);
|
| 39 |
return LocalDate.parse(dateString, SHORT_MONTH_DATE_YEAR_FORMATTER);
|
54 |
return LocalDate.parse(dateString, SHORT_MONTH_DATE_YEAR_FORMATTER);
|
| 40 |
}
|
55 |
}
|