Parse Accept-Language header in Java
The accept-language header in request is usually a long complex string - Eg. Accept-Language : en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2 Is there a simple way to parse it in java? Or a API to help me do that? Brett Kail I would suggest using ServletRequest.getLocales() to let the container parse Accept-Language rather than trying to manage the complexity yourself. Qiang Li For the record, now it is possible with Java 8 : Locale.LanguageRange.parse() Here's an alternative way to parse the Accept-Language header which doesn't require a servlet container: String header = "en-ca,en;q=0.8,en