Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Locale;

public class Main {
    public static String getValidLocale(String locale) {

        if ("en".equalsIgnoreCase(locale)) {
            return "en";
        } else if ("es".equalsIgnoreCase(locale)) {
            return "es";
        } else if ("pt".equalsIgnoreCase(locale)) {
            return "pt";
        } else {
            return getDeviceLocale();
        }
    }

    public static String getDeviceLocale() {
        return Locale.getDefault().getLanguage();
    }
}