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:com.sanbo.moveonapp.MainActivity.java

@Override
public void onRestart() {
    super.onRestart();
    int savedVersionNumber;
    SharedPreferences myShared;//from   w  ww  .  j a  v a2 s  .  co m
    PackageInfo pi;
    String initPrefs = "moveonapp_init_prefs";
    String versionNumber = "version_number";
    int currentVersionNumber = 0;
    if (Config.DEBUG)
        Log.d(Config.LOGTAG, "MainActivity.onCreate()");
    // MoveOnApp Preferences
    pref = PreferenceManager.getDefaultSharedPreferences(this);
    myPublic.getmPreferences().setmContext(this);
    myShared = getSharedPreferences(initPrefs, Context.MODE_PRIVATE);
    savedVersionNumber = myShared.getInt(versionNumber, 0);
    try {
        pi = getPackageManager().getPackageInfo(getPackageName(), 0);
        currentVersionNumber = pi.versionCode;
    } catch (Exception e) {
    }
    if (currentVersionNumber > savedVersionNumber) {
        //Test data from SharedPreferences and first use

        Editor editor = pref.edit();
        editor.putString(Config.meter_options, Config.MyDISTANCE);
        editor.putString(Config.user_options, Config.MyUSER);
        editor.putString(Config.route_options, Config.MyROUTE);
        editor.putString(Config.language_options, Config.MyLANGUAGE);
        editor.putBoolean(Config.show_options, Config.isTRUE);
        editor.putBoolean(Config.transfer_options, Config.isTRUE);
        editor.commit();

        // Here we can show in next versions NEW FEATURES           
        //new NewFeaturesDialog(this).show();

        Editor editor0 = myShared.edit();
        editor0.putInt(versionNumber, 0);
        editor0.putInt(versionNumber, currentVersionNumber);
        editor0.commit();
    }
    // force to refresh preferences
    myPublic.getmPreferences().set_check();
    //getting the language from SharedPreferences, by default is "en"
    try {
        String tmp = pref.getString(Config.language_options, "");
        if (tmp == "") {
            myLang = TypeLanguage.ENGLISH;
        } else {
            myLang = TypeLanguage.typeOf(tmp);
        }
        Locale myLocale = new Locale(myLang.toString());
        Locale.setDefault(myLocale);
        android.content.res.Configuration config = new android.content.res.Configuration();
        config.locale = myLocale;
        getBaseContext().getResources().updateConfiguration(config,
                getBaseContext().getResources().getDisplayMetrics());
    } catch (Exception e) {
        Log.e(Config.LOGTAG, "MainActiviti.onCreate setting_language_preference");
    }
    // Tenemos una plantilla llamada activity_main.xml donde mostraremos la informacin que queramos (logotipo, etc.)
    setContentView(R.layout.activity_main);

    new Handler().postDelayed(new Runnable() {
        public void run() {
            // Cuando pasen los 1 segundo, pasamos a la actividad principal de la aplicacin
            Intent intent = new Intent(MainActivity.this, LoadingActivity.class);
            startActivity(intent);
            finish();
        };
    }, DURACION_SPLASH);
}

From source file:com.amagi82.kerbalspaceapp.CelestialBodyActivity.java

@Override
public void onConfigurationChanged(Configuration config) {
    super.onConfigurationChanged(config);
    if (Settings.language == null) {
        Settings.language = Locale.getDefault();
    } else if (!config.locale.equals(Settings.language) && !Locale.getDefault().equals(Settings.language)) {
        config.locale = Settings.language;
        Locale.setDefault(config.locale);
        getBaseContext().getResources().updateConfiguration(config, getResources().getDisplayMetrics());
        recreate();/*from   ww  w  . j a  v  a2 s . com*/
    }
}

From source file:es.uvigo.ei.sing.laimages.core.entities.datasets.HorizontalElementDatasetTest.java

@Test
public void testElementDataToCSVVWithLibreOfficeFormatES() throws IOException {
    Locale.setDefault(new Locale("es", "ES"));

    File exportFile = exportElementToTmpCSVFile(TEST_ELEMENT_DATA, FileFormat.LIBRE_OFFICE);

    assertTrue(FileUtils.contentEquals(TEST_ELEMENT_DATA_LIBRE_OFFICE_ES, exportFile));
}

From source file:com.netscape.admin.certsrv.Console.java

/**
  * common initialization routine./*from  w ww . j a  v  a  2  s  . c  om*/
  *
  * @param language   language string. For example, "en" for english
  */
protected static void common_init(String language) {
    Locale.setDefault(new Locale(language, Locale.getDefault().getCountry()));

    try {

        // bug 115085: init calls needs to be inside the try block as, on Unix, during
        // initialization any call to java.awt.* will cause an exception to be thrown
        // if Xserver is not accessable. The jvm prints correctly the error message about
        // unaccessable Xserver but exception stack trace makes it less readable

        if (_info == null)
            _info = new ConsoleInfo();

        PreferenceManager.setLocalStorageFlag(_preferences.getBoolean(PREFERENCE_LOCAL, false));

        if (!_useJavaLookAndFeel) {
            SuiLookAndFeel nmclf = new SuiLookAndFeel();
            UIManager.setLookAndFeel(nmclf);

            // With JDK1.4 on Unix, the first instance of JFileChooser
            // has an incorrect layout for some of the buttons. Create
            // and discard an instance.
            if (!_isWindows) {
                new JFileChooser();
            }
        }
        FontFactory.initializeLFFonts(); // load default customized fonts for login/splash

    } catch (InternalError ie) {
        System.err.println("Console: " + ie.getMessage());
        System.exit(1);
    } catch (Exception e) {
        Debug.println("Console.common_init: Cannot init " + e);
    }
}

From source file:pcgen.system.Main.java

private static void configureUI() {
    Utility.configurePlatformUI();// w  w w. j  av a  2  s.  c o  m
    String language = ConfigurationSettings.getLanguage();
    String country = ConfigurationSettings.getCountry();
    if (StringUtils.isNotEmpty(language) && StringUtils.isNotEmpty(country)) {
        Locale.setDefault(new Locale(language, country));
    }
    LanguageBundle.init();
    LookAndFeelManager.initLookAndFeel();
    Utility.setApplicationTitle(Constants.APPLICATION_NAME);
}

From source file:com.amagi82.kerbalspaceapp.MainActivity.java

@Override
public void onConfigurationChanged(Configuration config) {
    super.onConfigurationChanged(config);
    // Pass any configuration change to the drawer toggle
    mDrawerToggle.onConfigurationChanged(config);
    if (Settings.language == null) {
        Settings.language = Locale.getDefault();
    } else if (!config.locale.equals(Settings.language) && !Locale.getDefault().equals(Settings.language)) {
        config.locale = Settings.language;
        Locale.setDefault(config.locale);
        getBaseContext().getResources().updateConfiguration(config, getResources().getDisplayMetrics());
        recreate();//w w  w . j ava2 s  . c  om
    }
}

From source file:es.uvigo.ei.sing.laimages.core.entities.datasets.HorizontalElementDatasetTest.java

@Test
public void testElementDataToCSVVWithLibreOfficeFormatUS() throws IOException {
    Locale.setDefault(new Locale("en", "US"));

    File exportFile = exportElementToTmpCSVFile(TEST_ELEMENT_DATA, FileFormat.LIBRE_OFFICE);

    assertTrue(FileUtils.contentEquals(TEST_ELEMENT_DATA_LIBRE_OFFICE_US, exportFile));
}

From source file:com.pdmanager.views.patient.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //    application = (VideoApp) getApplication();
    //  application.setContext(this);

    // application.addOperationChangeListener(this);
    //  application.addCallNegotiationListener(this);

    //  TelerikActivityHelper.updateActivityTaskDescription(this);
    try {//from  w w w  . j  av a2s. c om
        String languageToLoad = RecordingSettings.newInstance(this.getApplicationContext()).getLang(); // your language
        Locale locale = new Locale(languageToLoad);
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale;
        getBaseContext().getResources().updateConfiguration(config,
                getBaseContext().getResources().getDisplayMetrics());

        Resources resources = getResources();
        ColorDrawable bgColorPrimary = new ColorDrawable(resources.getColor(R.color.primary_title_background));
        ColorDrawable bgColorSecondary = new ColorDrawable(
                resources.getColor(R.color.secondary_title_background));
        currentBgColor = bgColorSecondary;
        setContentView(R.layout.activity_main);
        Toolbar tb = (Toolbar) this.findViewById(R.id.toolbar);
        this.setSupportActionBar(tb);
        if (tb != null) {
            tb.setTitleTextColor(Color.WHITE);
            setOverflowButtonColor(tb, Color.WHITE);
        }
        actionBar = getSupportActionBar();

        if (actionBar != null) {
            actionBar.setBackgroundDrawable(currentBgColor);
        }
        this.setupActionBar();

        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        ///Set Brightness
        float SysBackLightValue = 255f;

        //  android.provider.Settings.System.putInt(BatteryBoosterActivity.this.getContentResolver(),   android.provider.Settings.System.SCREEN_BRIGHTNESS,(int) SysBackLightValue);
        //  Window myWindow =BatteryBoosterActivity.this. getWindow();
        //  WindowManager.LayoutParams winParams = myWindow.getAttributes();                                    winParams.screenBrightness = 255f;
        //  myWindow.setAttributes(winParams);
    } catch (Exception ex) {
        Log.e("MAINACTIVITY", "RES", ex.getCause());

    }

    //RecordingSettingsHandler.getInstance().Init(getApplicationContext());

    /*    try {
    this.setupAlertFragmentManager();
        }
        catch (Exception ex)
        {
    Log.e("MAINACTIVITY","RES",ex.getCause());
            
        }
        */

    if (savedInstanceState == null) {

    }
    try {
        Bundle extras = this.getIntent().getExtras();

        if (extras != null) {

            String alertType = extras.getString(PDApplicationContext.INTENT_ALERT_TYPE);
            String alertId = extras.getString(PDApplicationContext.INTENT_ALERT_ID);

            if (alertType != null && alertId != null) {

                Log.d("MAINACTIVITY", alertType);

            } else {
                Log.d("MAINACTIVITY", "NULL Alert type");
            }
        }
    } catch (Exception ex) {
        Log.e("MAINACTIVITY", "INTENT", ex.getCause());

    }

    initFragment();
}

From source file:org.jfree.data.time.junit.MillisecondTest.java

/**
 * Some checks for the getFirstMillisecond() method.
 *//* w  w w.j av a2 s . c o  m*/
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Millisecond m = new Millisecond(500, 15, 43, 15, 1, 4, 2006);
    assertEquals(1143902595500L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}