Comparing User countries with Event countries

 
  • Comparing User countries with Event countries

    Hi,

    My research application is comparing User countries (User.getInfo) and Event countries (Event.getInfo). Can you tell me where I can get a list to match these correctly up?

    More specifically:
    <event ..>
    <venue ..>
    <location>
    <country>United Kingdom</country>
    ..
    </location>
    ..
    </event>

    AND

    <user>
    ..
    <country>UK</country>
    ..
    </user>

    My current solution (simplified) in Java is:
    Locale[] availableLocales = Locale.getAvailableLocales();
    for (Locale l : availableLocales) {
    l.getCountry(); // gives back the 2 letter code
    l.getDisplayCountry(); // gives back the long country name
    }

    The problem here is that it doesn't work for ALL countries, e.g. United Kingdom has the 2 letter code "GB" (Java) instead of "UK" (Last.fm API).

    Wikipedia lists the ISO 3166-1 alpha-2 codes (that also use GB for United Kingdom by the way) here:
    http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements

    Thanks!

    Patrick

    • JRoar sa...
    • Alumni
    • 13 apr 2012, 09:21
    I believe you'll only run into this problem with UK, so for all other cases your idea should work fine. I agree, though, that there should really be a machine readable form of the event's country in the response.

    Also be sure to call getDisplayCountry(Locale.ENGLISH)

Anonyma användare kan inte skriva inlägg. Vänligen logga in eller skapa ett konto för att göra inlägg i forumen.