0

I am getting some issue when I am trying to add support for locale in JSF primefaces calendar.

I'm passing locale & have also added the locale js file for calendar UI support. But when user select the date from calendar & after that I have below java code to parse the date & to validate the date.

Current locale : fr Suppose user select "21-Aoû-2015" from UI calendar. But for java date format

   "21-Aug-2015" in fr locale is "21-août-2015".

Similarly :

   "10-Apr-2019" is "10-avr.-2019"

I'm using below code & selected locale is "fr":

    Date date = null;
    boolean isDateValid = false;
    for (String pattern : patterns) {

        DateFormat df = new SimpleDateFormat(pattern, locale);
        try {
            date = df.parse(value);

            String newDateString = df.format(date);
            System.out.println(newDateString);

            isDateValid = true;
            break;

        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    System.out.println("Date : " + date);

So, the main reason, I found is that java DateFormat parse mis-match. i.e.: When locale is "fr" french.

Java parse :

For "fr" locale -

Aug => "août" instead of "Aoû"

Apr => "avr." instead of "Avr"

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Sharry India
  • 341
  • 1
  • 9

0 Answers0