cancel
Showing results for 
Search instead for 
Did you mean: 

Country Locale, Null pointer exception , Error few times

Former Member
0 Kudos

Hi Expetrs,

I am using the following code in my WD applucation. It retrives country locale value.

// Retrive the local locale (country)

final String CURRENT_SESSION_LOCALE = WDResourceHandler.getCurrentSessionLocale().toString();

country_local = CURRENT_SESSION_LOCALE.substring(3).trim();

The above code is working . But some times not working and throughs exceptions

'Null Pointer Exception'

'IndexRangeOutOfBoundException'

Could any one figure it out why its failing few times. Is is Cache issue, Or Portal Memory issues?

I appreciate your tips and helpfull information on this. I will award points for answers.

Thank you

Maruti

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Don't fiddle around with string representation of locale.

Use something like

Locale sessionLocale = WDResourceHandler.getCurrentSessionLocale();
String country = sessionLocale.getCountry();

See java.util.Locale Javadoc:

    /**
     * Returns the country/region code for this locale, which will
     * either be the empty string or an uppercase ISO 3166 2-letter code.
     * @see #getDisplayCountry
     */
    public String getCountry() {
        return country;
    }

Armin