Java Code Examples for java.util.Locale.setDefault()

The following are Jave code examples for showing how to use setDefault() of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: NetigsoDuplicatedClassForNameTest.java   View Source Code Vote up 6 votes
@Override
    protected void setUp() throws Exception {
        Locale.setDefault(new Locale("te", "ST"));
        clearWorkDir();
        File ud = new File(getWorkDir(), "ud");
        ud.mkdirs();
        System.setProperty("netbeans.user", ud.getPath());

        data = new File(getDataDir(), "jars");
        jars = new File(getWorkDir(), "space in path");
        jars.mkdirs();
        simpleModule = createTestJAR("simple-module", null);
        
        String snd =
            "Manifest-Version: 1.0\n" +
"OpenIDE-Module: org.foo2/1\n" +
"OpenIDE-Module-Name: Second Foo test module\n" +
"OpenIDE-Module-Specification-Version: 1.2"
          + "";
        simpleModule2 = changeManifest(simpleModule, snd);
        
        dependsModule = createTestJAR("depends-on-simple-module", null, simpleModule);
    }
 
Example 2
Project: openjdk-jdk10   File: Regression.java   View Source Code Vote up 6 votes
public void Test4058613() {
    // Creating a default collator doesn't work when Korean is the default
    // locale

    Locale oldDefault = Locale.getDefault();

    Locale.setDefault( Locale.KOREAN );
    try {
        Collator c = Collator.getInstance();

        // Since the fix to this bug was to turn of decomposition for Korean collators,
        // ensure that's what we got
        if (c.getDecomposition() != Collator.NO_DECOMPOSITION) {
          errln("Decomposition is not set to NO_DECOMPOSITION");
        }
    }
    finally {
        Locale.setDefault(oldDefault);
    }
}
 
Example 3
Project: parabuild-ci   File: YearTests.java   View Source Code Vote up 5 votes
/**
 * Some checks for the getLastMillisecond() method.
 */
public void testGetLastMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    Year y = new Year(1970);
    // TODO: Check this result...
    assertEquals(31532399999L, y.getLastMillisecond());
    Locale.setDefault(saved);
}
 
Example 4
Project: traccar-service   File: Main.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws Exception {
    Locale.setDefault(Locale.ENGLISH);

    Context.init(args);
    Log.info("Starting server...");

    Context.getServerManager().start();
    if (Context.getWebServer() != null) {
        Context.getWebServer().start();
    }

    new Timer().scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            try {
                Context.getDataManager().clearHistory();
            } catch (SQLException error) {
                Log.warning(error);
            }
        }
    }, 0, CLEAN_PERIOD);

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            Log.info("Shutting down server...");

            if (Context.getWebServer() != null) {
                Context.getWebServer().stop();
            }
            Context.getServerManager().stop();
        }
    });
}
 
Example 5
Project: parabuild-ci   File: SecondTests.java   View Source Code Vote up 5 votes
/**
 * Some checks for the getStart() method.
 */
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);        
}
 
Example 6
Project: OpenHub   File: AppUtils.java   View Source Code Vote up 5 votes
private static void updateResources(Context context, String language) {
    Locale locale = getLocale(language);
    Locale.setDefault(locale);
    Configuration configuration = context.getResources().getConfiguration();
    configuration.setLocale(locale);
    context.createConfigurationContext(configuration);
}
 
Example 7
Project: parabuild-ci   File: MonthTests.java   View Source Code Vote up 5 votes
/**
 * Some checks for the getFirstMillisecond() method.
 */
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    Month m = new Month(3, 1970);
    assertEquals(5094000000L, m.getFirstMillisecond());
    Locale.setDefault(saved);
}
 
Example 8
Project: incubator-netbeans   File: NetigsoMetaInfServicesTest.java   View Source Code Vote up 5 votes
protected @Override void setUp() throws Exception {
    Locale.setDefault(Locale.US);
    clearWorkDir();
    File ud = new File(getWorkDir(), "ud");
    ud.mkdirs();
    System.setProperty("netbeans.user", ud.getPath());
    
    data = new File(getDataDir(), "jars");
    jars = new File(getWorkDir(), "space in path");
    jars.mkdirs();
    File simpleModule = createTestJAR("activate", null);
}
 
Example 9
Project: openjdk-jdk10   File: bug8020708.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws Exception {
    for (Locale locale : SUPPORTED_LOCALES) {
        for (String laf : LOOK_AND_FEELS) {
            Locale.setDefault(locale);
            if (!installLookAndFeel(laf)) {
                continue;
            }
            testInternalFrameMnemonic();
        }
    }
}
 
Example 10
Project: android-perftracking   File: EnvironmentInfoSpec.java   View Source Code Vote up 5 votes
@Test
public void shouldPointToDefaultCountryAndRegionWhenLocationIsNotUpdated() {
  tm = null;
  Locale.setDefault(new Locale("testLanguage", "Test-Locale-Country", "testVariant"));
  EnvironmentInfo info = new EnvironmentInfo(ctx, location, batteryinfo);

  assertThat(info.getRegion()).isEqualTo(null);
  assertThat(info.getCountry()).isEqualTo("TEST-LOCALE-COUNTRY");
}
 
Example 11
Project: incubator-netbeans   File: NetigsoLayerTest.java   View Source Code Vote up 5 votes
protected @Override void setUp() throws Exception {
        Locale.setDefault(Locale.US);
        clearWorkDir();
//        NetigsoModuleFactory.clear();

        
        data = new File(getDataDir(), "jars");
        jars = new File(getWorkDir(), "jars");
        jars.mkdirs();
        File simpleModule = createTestJAR("simple-module", null);
        File dependsOnSimpleModule = createTestJAR("depends-on-simple-module", null, simpleModule);

        if (System.getProperty("netbeans.user") == null) {
            File ud = new File(getWorkDir(), "ud");
            ud.mkdirs();

            System.setProperty("netbeans.user", ud.getPath());


            ModuleSystem ms = Main.getModuleSystem();
            mgr = ms.getManager();
            mgr.mutexPrivileged().enterWriteAccess();
            try {
                File j1 = new File(jars, "simple-module.jar");
                m1 = mgr.create(j1, null, false, false, false);
                mgr.enable(Collections.<Module>singleton(m1));
            } finally {
                mgr.mutexPrivileged().exitWriteAccess();
            }
        }

    }
 
Example 12
Project: incubator-netbeans   File: SetupHid.java   View Source Code Vote up 5 votes
protected @Override void setUp() throws Exception {
    Locale.setDefault(Locale.US);
    clearWorkDir();
    data = new File(getDataDir(), "jars");
    jars = new File(getWorkDir(), "jars");
    jars.mkdirs();
    createTestJARs();
    
    File ud = new File(getWorkDir(), "ud");
    ud.mkdirs();
    
    System.setProperty("netbeans.user", ud.getPath());
}
 
Example 13
Project: openjdk-jdk10   File: DocLocale.java   View Source Code Vote up 5 votes
/**
 * Constructor
 */
DocLocale(DocEnv docenv, String localeName, boolean useBreakIterator) {
    this.docenv = docenv;
    this.localeName = localeName;
    this.useBreakIterator = useBreakIterator;
    locale = getLocale();
    if (locale == null) {
        docenv.exit();
    } else {
        Locale.setDefault(locale); // NOTE: updating global state
    }
    collator = Collator.getInstance(locale);
    sentenceBreaker = BreakIterator.getSentenceInstance(locale);
}
 
Example 14
Project: parabuild-ci   File: QuarterTests.java   View Source Code Vote up 5 votes
/**
 * Some checks for the getEnd() method.
 */
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);                
}
 
Example 15
Project: catalog-api-demo   File: MoneysTest.java   View Source Code Vote up 5 votes
@Test public void format_japanese_yen() {
  assertThat(format($(123, JPY))).isEqualTo("JPY123");
  assertThat(format($(123456, JPY))).isEqualTo("JPY123,456");

  Locale.setDefault(Locale.JAPAN);
  assertThat(format($(123, JPY))).isEqualTo("¥123");
  assertThat(format($(123456, JPY))).isEqualTo("¥123,456");
}
 
Example 16
Project: ProyectoPacientes   File: StatementRegressionTest.java   View Source Code Vote up 4 votes
public void testBug11540() throws Exception {
    Locale originalLocale = Locale.getDefault();
    Connection thaiConn = null;
    Statement thaiStmt = null;
    PreparedStatement thaiPrepStmt = null;

    try {
        createTable("testBug11540", "(field1 DATE, field2 TIMESTAMP)");
        this.stmt.executeUpdate("INSERT INTO testBug11540 VALUES (NOW(), NOW())");
        Locale.setDefault(new Locale("th", "TH"));
        Properties props = new Properties();
        props.setProperty("jdbcCompliantTruncation", "false");

        thaiConn = getConnectionWithProps(props);
        thaiStmt = thaiConn.createStatement();

        this.rs = thaiStmt.executeQuery("SELECT field1, field2 FROM testBug11540");
        this.rs.next();

        Date origDate = this.rs.getDate(1);
        Timestamp origTimestamp = this.rs.getTimestamp(1);
        this.rs.close();

        thaiStmt.executeUpdate("TRUNCATE TABLE testBug11540");

        thaiPrepStmt = ((com.mysql.jdbc.Connection) thaiConn).clientPrepareStatement("INSERT INTO testBug11540 VALUES (?,?)");
        thaiPrepStmt.setDate(1, origDate);
        thaiPrepStmt.setTimestamp(2, origTimestamp);
        thaiPrepStmt.executeUpdate();

        this.rs = thaiStmt.executeQuery("SELECT field1, field2 FROM testBug11540");
        this.rs.next();

        Date testDate = this.rs.getDate(1);
        Timestamp testTimestamp = this.rs.getTimestamp(1);
        this.rs.close();

        assertEquals(origDate, testDate);
        assertEquals(origTimestamp, testTimestamp);

    } finally {
        Locale.setDefault(originalLocale);
    }
}
 
Example 17
Project: micrometer   File: InfluxMeterRegistryFieldToStringTest.java   View Source Code Vote up 4 votes
@AfterEach
public void cleanUp() {
    Locale.setDefault(this.originalLocale);
}
 
Example 18
Project: jaffa-framework   File: ApplicationResourceLoaderTest.java   View Source Code Vote up 4 votes
@Test
public void testApplicationResourceLoader() {

	/*
	 * ApplicationResourceLoader Test
	 */
	ApplicationResourceLoader resourceLoader = ApplicationResourceLoader.getInstance();

	String defaultResourceLoadResult = (resourceLoader.getApplicationResources().get("") == null
			|| resourceLoader.getApplicationResources().get("").size() < 1) ? "Default Resource Load Fail"
					: "Default Resource Load Success";

	String localeResourceLoadResult = (resourceLoader.getApplicationResources().get("ar_OM") == null
			|| resourceLoader.getApplicationResources().get("ar_OM").size() < 1) ? "Locale Resource Load Fail"
					: "Locale Resource Load Success";

	// Checking provided two resources available in memory(this include
	// extra one for default to use it in label editor)
	assertEquals(4, resourceLoader.getApplicationResources().size());

	// Default Resource
	assertEquals("Default Resource Load Success", defaultResourceLoadResult);

	// Locale Specific Resource
	assertEquals("Locale Resource Load Success", localeResourceLoadResult);

	// Override resource check
	assertEquals("Printer Name", resourceLoader.getApplicationResources().get("")
			.getProperty("label.Jaffa.Printing.PrinterDefinition.RealPrinterName"));

	assertEquals("Edit Label",
			resourceLoader.getApplicationResources().get("").getProperty("label.Jaffa.Admin.LabelEditor.Label"));

	assertEquals("Label",
			resourceLoader.getApplicationResourcesDefault().get("label.Jaffa.Admin.LabelEditor.Label"));

	assertEquals("Edit Label",
			resourceLoader.getApplicationResourcesOverride().get("label.Jaffa.Admin.LabelEditor.Label"));

	
	/*
	 * PropertyMessageResources Test
	 */

	// Default Language Test
	assertEquals("Edit Label", MessageHelper.findMessage("label.Jaffa.Admin.LabelEditor.Label", null));

	// Locale ar_OM Test
	Locale.setDefault(new Locale.Builder().setLanguage("ar").setRegion("OM").build());
	assertNotNull(MessageHelper.findMessage("label.Jaffa.Admin.LabelEditor.Label", null));
}
 
Example 19
Project: openjdk-jdk10   File: MletParserLocaleTest.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws Exception {

        boolean error = false;

        // Instantiate the MBean server
        //
        System.out.println("Create the MBean server");
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();

        // Get Default Locale
        Locale loc = Locale.getDefault();

        // Instantiate an MLet
        //
        System.out.println("Create the MLet");
        MLet mlet = new MLet();

        // Register the MLet MBean with the MBeanServer
        //
        System.out.println("Register the MLet MBean");
        ObjectName mletObjectName = new ObjectName("Test:type=MLet");
        mbs.registerMBean(mlet, mletObjectName);

        // Call getMBeansFromURL
        //
        System.out.println("Call mlet.getMBeansFromURL(<url>)");
        String testSrc = System.getProperty("test.src");
        System.out.println("test.src = " + testSrc);
        String urlCodebase;
        if (testSrc.startsWith("/")) {
            urlCodebase =
                "file:" + testSrc.replace(File.separatorChar, '/') + "/";
        } else {
            urlCodebase =
                "file:/" + testSrc.replace(File.separatorChar, '/') + "/";
        }
        String mletFile = urlCodebase + args[0];
        System.out.println("MLet File = " + mletFile);
        try {
            // Change default Locale to Turkish
            Locale.setDefault(new Locale("tr", "TR"));
            mlet.getMBeansFromURL(mletFile);
            System.out.println("Test Passes");
        } catch (Exception e) {
            error = true;
            e.printStackTrace(System.out);
        }finally {
            Locale.setDefault(loc);
        }

        // Unregister the MLet MBean
        //
        System.out.println("Unregister the MLet MBean");
        mbs.unregisterMBean(mletObjectName);

        // Release MBean server
        //
        System.out.println("Release the MBean server");
        MBeanServerFactory.releaseMBeanServer(mbs);

        // End Test
        //
        System.out.println("Bye! Bye!");
        if (error) System.exit(1);
    }
 
Example 20
Project: doctemplate   File: FormatHelperTest.java   View Source Code Vote up 4 votes
/**
 * Initialize Test
 */
@Before
public void doBefore() {

	Locale.setDefault(new Locale("en", "GB"));
}