Coming late to this question, but now you can use BCP47J, a Java library that provides several functions related to BCP47 language tags.