Author: tchemit Date: 2014-03-31 17:52:19 +0200 (Mon, 31 Mar 2014) New Revision: 1783 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1783 Log: refs #4483 fix locale change Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/MonthConverter.java Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/MonthConverter.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/MonthConverter.java 2014-03-31 15:36:31 UTC (rev 1782) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/MonthConverter.java 2014-03-31 15:52:19 UTC (rev 1783) @@ -58,16 +58,20 @@ Locale locale = (Locale) map.get(ActionContext.LOCALE); Preconditions.checkNotNull(locale, "No locale found in ActionContext"); - try { - parsedValue = WaoUtils.parseMonth(locale, string); - } catch (ParseException e) { - if (log.isErrorEnabled()) { - log.error("Could not format parse date " + string, e); + + parsedValue = parseDate(locale, string, strings, true); + + if (parsedValue == null) { + + //FIXME If action is changing language, then date are not in good format + //FIXME Let's try why other locale... + if (Locale.FRENCH.equals(locale)) { + locale = Locale.ENGLISH; + } else { + locale = Locale.FRENCH; } - //FIXME Find out why we don't see the error - throw new TypeConversionException("strings=" + Arrays.toString(strings)); + parsedValue = parseDate(locale, string, strings, false); } - } return parsedValue; @@ -75,7 +79,22 @@ } else { throw new TypeConversionException("strings=" + Arrays.toString(strings)); } + } + protected Date parseDate(Locale locale, String string, String[] strings, boolean swallonError) { + Preconditions.checkNotNull(locale); + try { + return WaoUtils.parseMonth(locale, string); + } catch (ParseException e) { + if (swallonError) { + return null; + } + //FIXME See why we don't see the error + if (log.isErrorEnabled()) { + log.error("Could not format parse date " + string, e); + } + throw new TypeConversionException("strings=" + Arrays.toString(strings)); + } } @Override