List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:org.dbhatt.d_deleted_contact.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_restore_all: if (Build.VERSION.SDK_INT > 22) { if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_CONTACTS) == PackageManager.PERMISSION_GRANTED) { restore_all_contacts();//from w w w . j av a 2 s . c o m } else { final MainActivity mainActivity = this; if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_CONTACTS)) { new AlertDialog.Builder(this).setTitle(R.string.permission) .setMessage(R.string.permission_message_write_external_storage) .setPositiveButton(R.string.permission_grant, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish_activity = false; ActivityCompat.requestPermissions(mainActivity, new String[] { Manifest.permission.WRITE_CONTACTS }, REQUEST_WRITE_CONTACTS_CONTACT); } }) .create().show(); } else { finish_activity = false; ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_CONTACTS }, REQUEST_WRITE_CONTACTS_CONTACT); } } } else { restore_all_contacts(); } break; case R.id.action_app_invite: finish_activity = false; GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(AppInvite.API) .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() { @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } }).build(); Intent app_invite_intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invite_title)) .setMessage(getString(R.string.invite_message)) .setEmailSubject(getString(R.string.invite_email_subject)) .setEmailHtmlContent("<html><h2 class='h2'><a href='%%APPINVITE_LINK_PLACEHOLDER%%'>" + getString(R.string.app_name) + "</a></h2></html>") .build(); startActivityForResult(app_invite_intent, APP_INVITE); break; case R.id.action_share: finish_activity = false; Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("application/zip"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(getApplicationInfo().sourceDir))); startActivityForResult(Intent.createChooser(intent, getString(R.string.share)), APP_INVITE); break; case R.id.action_contact_us: finish_activity = false; startActivityForResult(new Intent(getApplicationContext(), Contact_us.class), DO_NOT_FINISH_REQUEST_CODE); break; case R.id.action_refresh: if (refreshing) Toast.makeText(this, R.string.try_after_some_time, Toast.LENGTH_SHORT).show(); else load_contacts(); break; case R.id.action_language: try { new AlertDialog.Builder(this).setTitle(R.string.action_language) .setNegativeButton(R.string.dismiss, null) .setItems(R.array.languages, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Locale locale = new Locale(getApplicationContext().getResources() .getStringArray(R.array.language_code)[which]); Locale.setDefault(locale); Configuration config = new Configuration(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) config.setLocale(locale); else config.locale = locale; getApplicationContext().getResources().updateConfiguration(config, null); startActivity(new Intent(getApplicationContext(), Splash.class)); finish(); } }).create().show(); } catch (Exception e) { e.printStackTrace(); } break; } return super.onOptionsItemSelected(item); }
From source file:org.jfree.data.time.junit.MinuteTest.java
/** * Some checks for the getStart() method. *///from w ww . j ava 2s .c o m public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 0); cal.set(Calendar.MILLISECOND, 0); Minute m = new Minute(47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getStart()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.jfree.data.time.WeekTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *//*from w ww . j a v a 2 s . co m*/ @Test public void testGetFirstMillisecondWithTimeZone() { Week w = new Week(47, 1950); Locale saved = Locale.getDefault(); Locale.setDefault(Locale.US); try { TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-603302400000L, w.getFirstMillisecond(zone)); } finally { Locale.setDefault(saved); } // try null calendar boolean pass = false; try { w.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.YearTest.java
/** * Some checks for the getStart() method. */// w ww.j a v a 2s. com @Test public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Year y = new Year(2006); assertEquals(cal.getTime(), y.getStart()); Locale.setDefault(saved); }
From source file:org.jfree.data.time.HourTest.java
/** * Some checks for the getStart() method. *///w w w .j a v a 2 s . co m @Test public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 0, 0); cal.set(Calendar.MILLISECOND, 0); Hour h = new Hour(3, 16, 1, 2006); assertEquals(cal.getTime(), h.getStart()); Locale.setDefault(saved); }
From source file:org.jfree.data.time.junit.SecondTest.java
/** * Some checks for the getStart() method. *//* w ww . j a va 2s . c om*/ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 0); Second s = new Second(55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), s.getStart()); Locale.setDefault(saved); }
From source file:de.tor.tribes.ui.windows.DSWorkbenchSplashScreen.java
/** * @param args the command line arguments *//*from www . ja va 2 s . c o m*/ public static void main(String args[]) { Locale.setDefault(Locale.GERMAN); int mode = -1; int minimal = 0; boolean ssd = false; if (args != null) { for (String arg : args) { switch (arg) { case "-d": case "--debug": //debug mode mode = 0; SystrayHelper.showInfoMessage("Running in debug mode"); break; case "-m": minimal = 1; break; case "-ssd": ssd = true; break; } } } Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); System.setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName()); if (mode == 0) { Configurator.setAllLevels(LogManager.getRootLogger().getName(), Level.DEBUG); } GlobalOptions.setMinimalVersion(minimal == 1); try { GlobalDefaults.initialize(); GlobalOptions.initialize(); //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { logger.error("Failed to setup LnF", e); } final boolean useSSD = ssd; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { DSWorkbenchSplashScreen.getSingleton().setLocationRelativeTo(null); if (useSSD) { DSWorkbenchSplashScreen.getSingleton().initializeSuperSpecialDebugFeatures(); } DSWorkbenchSplashScreen.getSingleton().setVisible(true); } catch (Exception e) { logger.error("Fatal application error", e); } } }); }
From source file:org.jfree.data.time.MillisecondTest.java
/** * Some checks for the getStart() method. *//*from ww w . j ava 2s . c om*/ @Test public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 555); Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getStart()); Locale.setDefault(saved); }
From source file:org.jfree.data.time.YearTest.java
/** * Some checks for the getEnd() method./* ww w . j a va 2 s . c o m*/ */ @Test public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.DECEMBER, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Year y = new Year(2006); assertEquals(cal.getTime(), y.getEnd()); Locale.setDefault(saved); }
From source file:org.jfree.data.time.HourTest.java
/** * Some checks for the getEnd() method./*from ww w .jav a 2s .com*/ */ @Test public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 8, 1, 59, 59); cal.set(Calendar.MILLISECOND, 999); Hour h = new Hour(1, 8, 1, 2006); assertEquals(cal.getTime(), h.getEnd()); Locale.setDefault(saved); }