Example usage for java.util Locale setDefault

List of usage examples for java.util Locale setDefault

Introduction

In this page you can find the example usage for java.util Locale setDefault.

Prototype

public static synchronized void setDefault(Locale newLocale) 

Source Link

Document

Sets the default locale for this instance of the Java Virtual Machine.

Usage

From source file:Main.java

public static void setCurrent(Context context, Locale locale) {
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;//from  w ww . ja  v a 2  s .c  om

    context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static void reloadLocale(Context context) {
    SharedPreferences sharedPrefs = PreferenceManager
            .getDefaultSharedPreferences(context.getApplicationContext());
    String lang = sharedPrefs.getString(PREF_APP_LANGUAGE, Locale.getDefault().getLanguage());
    if (sharedPrefs.getString(PREF_APP_LANGUAGE, "").equalsIgnoreCase("")) {
        sharedPrefs.edit().putString(PREF_APP_LANGUAGE, lang).commit();
    }/*from  w ww  .j a va2  s. co  m*/
    Configuration newConfig = context.getResources().getConfiguration();

    if (!newConfig.locale.getLanguage().equals(lang)) {
        locale = new Locale(lang);
    }

    if (locale != null) {
        Locale.setDefault(locale);
        newConfig.locale = locale;
        context.getResources().updateConfiguration(newConfig, context.getResources().getDisplayMetrics());
    }
}

From source file:com.github.vatbub.tictactoe.view.Main.java

public static void main(String[] args) {
    Common.getInstance().setAppName("tictactoev2");
    FOKLogger.enableLoggingOfUncaughtExceptions();

    try {//from  ww  w . j a v a  2  s.  co  m
        applicationConfiguration = new Config(new URL(
                "https://raw.githubusercontent.com/vatbub/tictactoe/master/remoteconfig/client.properties"),
                Main.class.getResource("fallbackConfig.properties"), true,
                "tictactoeClientConfigCache.properties", true);
    } catch (IOException e) {
        FOKLogger.log(Main.class.getName(), Level.SEVERE, "Could not read the remote config", e);
    }

    for (String arg : args) {
        if (arg.toLowerCase().matches("mockappversion=.*")) {
            // Set the mock version
            String version = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            Common.getInstance().setMockAppVersion(version);
        } else if (arg.toLowerCase().matches("mockbuildnumber=.*")) {
            // Set the mock build number
            String buildnumber = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            Common.getInstance().setMockBuildNumber(buildnumber);
        } else if (arg.toLowerCase().matches("mockpackaging=.*")) {
            // Set the mock packaging
            String packaging = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            Common.getInstance().setMockPackaging(packaging);
        } else if (arg.toLowerCase().matches("locale=.*")) {
            // set the gui language
            String guiLanguageCode = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            FOKLogger.info(Main.class.getName(), "Setting language: " + guiLanguageCode);
            Locale.setDefault(new Locale(guiLanguageCode));
        }
    }

    launch(args);
}

From source file:org.jboss.aerogear.unifiedpush.rest.util.iOSApplicationUploadFormTest.java

@BeforeClass
public static void before() throws Exception {
    Locale.setDefault(Locale.ENGLISH);
    ValidatorFactory config = Validation.buildDefaultValidatorFactory();
    validator = config.getValidator();//from   ww  w  . j  a  v  a 2 s  . co  m
}

From source file:com.microsoft.windowsazure.core.tracing.util.JavaTracingInterceptorTest.java

@BeforeClass
public static void setUSLocale() {
    locale = Locale.getDefault();
    Locale.setDefault(Locale.US);
}

From source file:edu.ku.brc.specify.config.init.secwiz.SpecifyDBSecurityWizardFrame.java

/**
 * @param args//from   w w w  . j a v a2s .c  o m
 */
public static void main(String[] args) {
    // Set App Name, MUST be done very first thing!
    UIRegistry.setAppName("Specify"); //$NON-NLS-1$

    try {
        ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

    } catch (MissingResourceException ex) {
        Locale.setDefault(Locale.ENGLISH);
        UIRegistry.setResourceLocale(Locale.ENGLISH);
    }

    try {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }
    } catch (Exception e) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSecurityWizard.class, e);
        e.printStackTrace();
    }

    AppBase.processArgs(args);
    AppBase.setupTeeForStdErrStdOut(true, false);

    System.setProperty("appdatadir", "..");

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            // Then set this
            IconManager.setApplicationClass(Specify.class);
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

            // Load Local Prefs
            AppPreferences localPrefs = AppPreferences.getLocalPrefs();
            //try {
            //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+(new File(UIRegistry.getAppDataDir()).getCanonicalPath())+"]");
            //} catch (IOException ex) {}

            localPrefs.setDirPath(UIRegistry.getAppDataDir());

            // Check to see if we should check for a new version
            String VERSION_CHECK = "version_check.auto";
            if (localPrefs.getBoolean(VERSION_CHECK, null) == null) {
                localPrefs.putBoolean(VERSION_CHECK, true);
            }

            String EXTRA_CHECK = "extra.check";
            if (localPrefs.getBoolean(EXTRA_CHECK, null) == null) {
                localPrefs.putBoolean(EXTRA_CHECK, true);
            }

            if (UIHelper.isLinux()) {
                Specify.checkForSpecifyAppsRunning();
            }

            if (UIRegistry.isEmbedded()) {
                checkForMySQLProcesses();
            }

            Specify.setUpSystemProperties();

            final SpecifyDBSecurityWizardFrame wizardFrame = new SpecifyDBSecurityWizardFrame();

            if (localPrefs.getBoolean(VERSION_CHECK, true) && localPrefs.getBoolean(EXTRA_CHECK, true)) {
                try {
                    com.install4j.api.launcher.SplashScreen.hide();
                    ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback() {
                        public void exited(int exitValue) {
                            UIHelper.centerAndShow(wizardFrame);
                        }

                        public void prepareShutdown() {

                        }
                    };
                    ApplicationLauncher.launchApplication("100", null, true, callback);

                } catch (Exception ex) {
                    UIHelper.centerAndShow(wizardFrame);
                }
            } else {
                UIHelper.centerAndShow(wizardFrame);
            }
        }
    });
}

From source file:com.xyxy.platform.modules.core.beanvalidator.BeanValidatorsTest.java

@BeforeClass
public static void beforeClass() {
    // To avoid the non-English environment test failure on message asserts.
    Locale.setDefault(Locale.ENGLISH);
}

From source file:com.jayway.restassured.itest.java.XMLValidationITest.java

@BeforeClass
public static void setUpBeforeClass() {
    Locale.setDefault(Locale.ENGLISH);
}

From source file:com.jayway.restassured.itest.java.XMLValidationITest.java

@AfterClass
public static void tearDownAfterClass() {
    Locale.setDefault(INITIAL_LOCALE);
}

From source file:cc.kave.commons.pointsto.evaluation.ProjectTrainValidateEvaluation.java

public static void main(String[] args) throws IOException {
    Locale.setDefault(Locale.US);

    Path baseDir = Paths.get("E:\\Coding\\MT");
    Path usageStoresDir = baseDir.resolve("Usages");
    Path resultFile = baseDir.resolve("EvaluationResults").resolve("TrainValidate.txt");

    ProjectTrainValidateEvaluation evaluator = INJECTOR.getInstance(ProjectTrainValidateEvaluation.class);
    evaluator.run(usageStoresDir);/* ww w  .  jav a2 s. c  om*/

    INJECTOR.getInstance(ResultExporter.class).export(resultFile, evaluator.getResults().entrySet().stream()
            .flatMap(e -> e.getValue().stream().map(er -> ImmutablePair.of(e.getKey(), er))).map(p -> {
                return new String[] { CoReNames.vm2srcQualifiedType(p.left), p.right.training,
                        p.right.validation, String.format(Locale.US, "%.3f", p.right.score),
                        Integer.toString(p.right.numTrainingUsages),
                        Integer.toString(p.right.numValidationUsages) };
            }));

    INJECTOR.getInstance(ExecutorService.class).shutdown();
}