whenever I'm defining the timeframe being in German session language after changing to English lang. session (and vice versa) I'm getting the: java.text.ParseException: Unparseable date: "10.10.2018"
Here is the fragment:
Date startDateFormatted = DateUtils.convertDateToMinusDayNumber(cal, dayRange);
Date endDateFormatted = new Date();
if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate))
{
try
{
String datePattern = getLocalizedString("dd.MM.yyyy"); //
startDateFormatted = new SimpleDateFormat(datePattern).parse(startDate); // exception is throwing on this line
endDateFormatted = new SimpleDateFormat(datePattern).parse(endDate);
}
catch (final Exception e)
{
LOG.error(ERROR_DATE_PARSING, e);
}
}
getLocalizedString. Post its definition.DateandSimpleDateFormat. Those classes are poorly designed and long outdated, the latter in particular notoriously troublesome. Instead useLocalDateandDateTimeFormatter, both from java.time, the modern Java date and time API.startDatestring for any non-printing characters?