List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:org.jfree.data.time.QuarterTest.java
/** * Some checks for the getEnd() method.// ww w. ja v a 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.MARCH, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Quarter q = new Quarter(1, 2006); assertEquals(cal.getTime(), q.getEnd()); Locale.setDefault(saved); }
From source file:org.jfree.data.time.WeekTest.java
/** * Some checks for the getLastMillisecond(TimeZone) method. *///from w w w.ja v a 2s . c o m @Test public void testGetLastMillisecondWithTimeZone() { Week w = new Week(2, 1950); Locale saved = Locale.getDefault(); Locale.setDefault(Locale.US); try { TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-629913600001L, w.getLastMillisecond(zone)); } finally { Locale.setDefault(saved); } // try null zone boolean pass = false; try { w.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.junit.MonthTest.java
/** * Some checks for the getStart() method. */// ww w . java 2s .com public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.MARCH, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Month m = new Month(3, 2006); assertEquals(cal.getTime(), m.getStart()); Locale.setDefault(saved); }
From source file:org.jfree.data.time.junit.MillisecondTest.java
/** * Some checks for the getEnd() method./* w w w .j ava2s. c o m*/ */ public void testGetEnd() { 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.getEnd()); Locale.setDefault(saved); }
From source file:edu.ku.brc.specify.prefs.SystemPrefs.java
@Override public void savePrefs() { if (form.getValidator() == null || form.getValidator().hasChanged()) { super.savePrefs(); ValCheckBox chk = form.getCompById("2"); localPrefs.putBoolean(VERSION_CHECK, (Boolean) chk.getValue()); chk = form.getCompById("3"); remotePrefs.putBoolean(SEND_STATS, (Boolean) chk.getValue()); chk = form.getCompById("9"); remotePrefs.putBoolean(SEND_ISA_STATS, (Boolean) chk.getValue()); /* remove if worldwind is broken*/chk = form.getCompById(USE_WORLDWIND); /* remove if worldwind is broken*/localPrefs.putBoolean(USE_WORLDWIND, (Boolean) chk.getValue()); // /* remove if worldwind is broken*/chk = form.getCompById(SYSTEM_HasOpenGL); /* remove if worldwind is broken*/localPrefs.putBoolean(SYSTEM_HasOpenGL, (Boolean) chk.getValue()); // /* remove if worldwind is broken*/chk = form.getCompById(USE_WORLDWIND); /* remove if worldwind is broken*/localPrefs.putBoolean(USE_WORLDWIND, (Boolean) chk.getValue()); //chk = form.getCompById(ALWAYS_ASK_COLL); //localPrefs.putBoolean(ALWAYS_ASK_COLL, (Boolean)chk.getValue()); ValComboBox localeCBX = form.getCompById("5"); Locale item = (Locale) localeCBX.getComboBox().getSelectedItem(); if (item != null) { if (item.equals(UIRegistry.getPlatformLocale())) { localPrefs.remove("locale.lang"); localPrefs.remove("locale.country"); localPrefs.remove("locale.var"); //System.out.println("["+localPrefs.get("locale.lang", null)+"]"); Locale.setDefault(UIRegistry.getPlatformLocale()); } else { if (item.getLanguage() == null) { localPrefs.remove("locale.lang"); } else { localPrefs.put("locale.lang", item.getLanguage()); }/*from w w w.ja v a 2 s. c o m*/ if (item.getCountry() == null) { localPrefs.remove("locale.country"); } else { localPrefs.put("locale.country", item.getCountry()); } if (item.getVariant() == null) { localPrefs.remove("locale.var"); } else { localPrefs.put("locale.var", item.getVariant()); } } ValBrowseBtnPanel browse = form.getCompById("7"); if (browse != null) { String newSplashPath = browse.getValue().toString(); if (newSplashPath != null && (oldSplashPath == null || !oldSplashPath.equals(newSplashPath))) { if (newSplashPath.isEmpty()) { resetSplashImage(); localPrefs.remove(SPECIFY_BG_IMG_PATH); } else { localPrefs.put(SPECIFY_BG_IMG_PATH, newSplashPath); changeSplashImage(); } } } File cp = JasperReportsCache.getImagePath(); try { localPrefs.flush(); } catch (BackingStoreException ex) { } } } }
From source file:org.jfree.data.time.junit.DayTest.java
/** * Some checks for the getEnd() method.// ww w .j a v a2 s . com */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(1900, Calendar.JANUARY, 1, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Day d = new Day(1, 1, 1900); assertEquals(cal.getTime(), d.getEnd()); Locale.setDefault(saved); }
From source file:iqq.app.core.service.impl.SkinServiceImpl.java
@Override public void setDefaultFont(Font vFont) { UIManager.put("ToolTip.font", vFont); UIManager.put("Table.font", vFont); UIManager.put("TableHeader.font", vFont); UIManager.put("TextField.font", vFont); UIManager.put("ComboBox.font", vFont); UIManager.put("TextField.font", vFont); UIManager.put("PasswordField.font", vFont); UIManager.put("TextArea.font", vFont); UIManager.put("TextPane.font", vFont); UIManager.put("EditorPane.font", vFont); UIManager.put("FormattedTextField.font", vFont); UIManager.put("Button.font", vFont); UIManager.put("CheckBox.font", vFont); UIManager.put("RadioButton.font", vFont); UIManager.put("ToggleButton.font", vFont); UIManager.put("ProgressBar.font", vFont); UIManager.put("DesktopIcon.font", vFont); UIManager.put("TitledBorder.font", vFont); UIManager.put("Label.font", vFont); UIManager.put("List.font", vFont); UIManager.put("TabbedPane.font", vFont); UIManager.put("MenuBar.font", vFont); UIManager.put("Menu.font", vFont); UIManager.put("MenuItem.font", vFont); UIManager.put("PopupMenu.font", vFont); UIManager.put("CheckBoxMenuItem.font", vFont); UIManager.put("RadioButtonMenuItem.font", vFont); UIManager.put("Spinner.font", vFont); UIManager.put("Tree.font", vFont); UIManager.put("ToolBar.font", vFont); UIManager.put("OptionPane.messageFont", vFont); UIManager.put("OptionPane.buttonFont", vFont); UIManager.put("Tree.paintLines", false); // Tree UIManager.put("Tree.leftChildIndent", 0); // UIManager.put("Tree.arrowDown", getIconByKey("main/arrowDown")); // Tree UIManager.put("Tree.arrowLeft", getIconByKey("main/arrowLeft")); // WebLookAndFeel.globalControlFont = vFont; WebLookAndFeel.globalTextFont = vFont; WebLookAndFeel.globalTitleFont = vFont; WebLookAndFeel.globalTooltipFont = vFont; WebLookAndFeel.globalAcceleratorFont = vFont; WebLookAndFeel.menuItemAcceleratorFont = vFont; WebLookAndFeel.globalAlertFont = vFont; WebLookAndFeel.globalMenuFont = vFont; // ?weblaf// w ww .jav a 2 s . c om WebLookAndFeel.setDecorateAllWindows(false); WebLookAndFeel.install(); Locale.setDefault(Locale.CHINA); }
From source file:org.opencms.i18n.CmsLocaleManager.java
/** * Sets the default locale of the Java VM to <code>{@link Locale#ENGLISH}</code> if the * current default has any other language then English set.<p> * * This is required because otherwise the default (English) resource bundles * would not be displayed for the English locale if a translated default locale exists.<p> * //w ww.jav a2 s . c o m * Here's an example of how this issues shows up: * On a German server, the default locale usually is <code>{@link Locale#GERMAN}</code>. * All English translations for OpenCms are located in the "default" message files, for example * <code>org.opencms.i18n.message.properties</code>. If the German localization is installed, it will be * located in <code>org.opencms.i18n.message_de.properties</code>. If user has English selected * as his locale, the default Java lookup mechanism first tries to find * <code>org.opencms.i18n.message_en.properties</code>. However, this file does not exist, since the * English localization is kept in the default file. Next, the Java lookup mechanism tries to find the servers * default locale, which in this example is German. Since there is a German message file, the Java lookup mechanism * is finished and uses this German localization, not the default file. Therefore the * user get the German localization, not the English one. * Setting the default locale explicitly to English avoids this issue.<p> */ private static void setDefaultLocale() { // set the default locale to english // this is required because otherwise the default (english) resource bundles // would not be displayed for the english locale if a translated locale exists Locale oldLocale = Locale.getDefault(); if (!(Locale.ENGLISH.getLanguage().equals(oldLocale.getLanguage()))) { // default language is not English try { Locale.setDefault(Locale.ENGLISH); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_I18N_DEFAULT_LOCALE_2, Locale.ENGLISH, oldLocale)); } } catch (Exception e) { // any Exception: the locale has not been changed, so there may be issues with the English // localization but OpenCms will run in general CmsLog.INIT.error(Messages.get().getBundle().key(Messages.LOG_UNABLE_TO_SET_DEFAULT_LOCALE_2, Locale.ENGLISH, oldLocale), e); } } else { if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key(Messages.INIT_I18N_KEEPING_DEFAULT_LOCALE_1, oldLocale)); } } // initialize the static member with the new default m_defaultLocale = Locale.getDefault(); }
From source file:org.jfree.data.time.junit.MonthTest.java
/** * Some checks for the getEnd() method.// www.j a v a2 s .c om */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Month m = new Month(1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); }
From source file:ch.itemis.xdocker.ui.view.XdockerContainerBrowserView.java
@Override protected void processResult(XdockerJobStatus status) { if (status.isOK() && status.getArgument() instanceof List<?>) { Locale defLocale = Locale.getDefault(); try {//w w w . j ava 2 s. co m Locale.setDefault(Locale.UK); // we support only English! PrettyTime pt = new PrettyTime(); @SuppressWarnings("unchecked") List<Container> images = (List<Container>) status.getArgument(); for (Object obj : images) { Container container = obj instanceof Container ? (Container) obj : null; if (container == null) return; // something is very odd here... go away! if (!match(container)) continue; // skip because unwanted! TableItem item = new TableItem(table, SWT.NONE); List<String> elements = new ArrayList<String>(); // elements.add(substring(container.getId(), 0, 12)); elements.add(container.getId()); elements.add(container.getImage()); elements.add(container.getCommand()); elements.add(pt.format(new Date(container.getCreated() * 1000))); elements.add(container.getStatus()); StringBuffer ports = new StringBuffer(); for (ContainerPort port : container.getPorts()) { boolean hasIP, hasPublPort; if (hasIP = isNotBlank(port.getIp())) { ports.append(port.getIp()); } if (hasPublPort = port.getPublicPort() != null) { if (hasIP) { ports.append(":"); } ports.append(String.valueOf(port.getPublicPort())); } if (port.getPrivatePort() != null) { if (hasIP || hasPublPort) { ports.append("->"); } ports.append(String.valueOf(port.getPrivatePort())); } if (port.getType() != null) { ports.append("/"); ports.append(port.getType()); } ports.append(", "); } elements.add(ports.toString().endsWith(", ") ? ports.toString().substring(0, ports.toString().length() - 2) : ports.toString()); elements.add(StringUtils.join(container.getNames())); item.setText(elements.toArray(new String[] {})); } for (int i = 0, n = table.getColumnCount(); i < n; i++) { table.getColumn(i).pack(); } table.getColumn(0).setWidth(120); table.getColumn(1).setWidth(120); table.getColumn(2).setWidth(120); } finally { Locale.setDefault(defLocale); // restore to default... } } }