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.assignmentone.Asta4DSampleServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    // for a international application, we use root as default locale
    Locale.setDefault(Locale.ROOT);
    super.init(config);
}

From source file:ch.ralscha.extdirectspring_itest.UserInitBinderServiceTest.java

@Test
public void testPostWithoutDate() throws IOException {
    Locale.setDefault(Locale.ENGLISH);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("extTID", "1"));
    formparams.add(new BasicNameValuePair("extAction", "userServiceInitBinderService"));
    formparams.add(new BasicNameValuePair("extMethod", "updateUser"));
    formparams.add(new BasicNameValuePair("extType", "rpc"));
    formparams.add(new BasicNameValuePair("extUpload", "false"));
    formparams.add(new BasicNameValuePair("name", "Garner"));
    formparams.add(new BasicNameValuePair("firstName", "Joe"));
    formparams.add(new BasicNameValuePair("email", "test@test.com"));
    formparams.add(new BasicNameValuePair("age", "28"));
    formparams.add(new BasicNameValuePair("flag", "false"));
    formparams.add(new BasicNameValuePair("dateOfBirth", ""));
    UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formparams, "UTF-8");

    this.post.setEntity(postEntity);

    CloseableHttpResponse response = this.client.execute(this.post);
    try {/*w  w  w . j  ava  2  s.  co  m*/
        HttpEntity entity = response.getEntity();
        assertThat(entity).isNotNull();
        String responseString = EntityUtils.toString(entity);

        Map<String, Object> rootAsMap = this.mapper.readValue(responseString, Map.class);
        assertThat(rootAsMap).hasSize(5);
        assertThat(rootAsMap.get("method")).isEqualTo("updateUser");
        assertThat(rootAsMap.get("type")).isEqualTo("rpc");
        assertThat(rootAsMap.get("action")).isEqualTo("userServiceInitBinderService");
        assertThat(rootAsMap.get("tid")).isEqualTo(1);

        Map<String, Object> result = (Map<String, Object>) rootAsMap.get("result");
        assertThat(result).hasSize(6);
        assertThat(result.get("name")).isEqualTo("Garner");
        assertThat(result.get("firstName")).isEqualTo("Joe");
        assertThat(result.get("age")).isEqualTo(28);
        assertThat(result.get("email")).isEqualTo("test@test.com");
        assertThat(result.get("flag")).isEqualTo(Boolean.FALSE);
        assertThat(result.get("dateOfBirth")).isNull();
        assertThat(result.get("success")).isEqualTo(Boolean.TRUE);
    } finally {
        IOUtils.closeQuietly(response);
    }
}

From source file:com.example.oris1991.anotherme.ExternalCalendar.CalendarAdapter.java

public CalendarAdapter(Context c, GregorianCalendar monthCalendar) {
    CalendarAdapter.dayString = new ArrayList<String>();
    Locale.setDefault(Locale.US);
    month = monthCalendar;/*from www . j a  v a 2  s . c  om*/
    selectedDate = (GregorianCalendar) monthCalendar.clone();
    mContext = c;
    month.set(GregorianCalendar.DAY_OF_MONTH, 1);
    this.items = new ArrayList<String>();
    df = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
    curentDateString = df.format(selectedDate.getTime());
    refreshDays();
}

From source file:net.sf.dynamicreports.test.jasper.chart.XyLineChartTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<Integer> column1;
    TextColumnBuilder<Integer> column2;

    Locale.setDefault(Locale.ENGLISH);

    rb.columns(column1 = col.column("Column1", "field1", Integer.class),
            column2 = col.column("Column2", "field2", Integer.class))
            .summary(//from ww  w .j a va 2 s  .c  o m
                    cht.xyLineChart().setXValue(column1).series(cht.xySerie(column2)).setShowShapes(false)
                            .setShowLines(false),
                    cht.xyLineChart().setXValue(column1).series(cht.xySerie(column2))
                            .setXAxisFormat(cht.axisFormat().setLabel("category").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setLineColor(Color.LIGHT_GRAY)),
                    cht.xyLineChart().setXValue(column1).series(cht.xySerie(column2))
                            .setYAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00")
                                    .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1)
                                    .setRangeMaxValueExpression(15)));
}

From source file:com.becapps.easydownloader.utils.Utils.java

public static void langInit(Context context) {
    String storedDefLang = settings.getString("DEF_LANG", "");
    if (storedDefLang.isEmpty() && storedDefLang != null) {
        Locale defLocale = Locale.getDefault();
        String defLang = defLocale.getLanguage();
        settings.edit().putString("DEF_LANG", defLang).commit();
    }// w w  w.  jav  a2s.c o m

    String lang = settings.getString("lang", "default");
    Locale locale;
    if (!lang.equals("default")) {
        String[] fLang = filterLang(lang);
        locale = new Locale(fLang[0], fLang[1]);
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale;
    } else {
        locale = new Locale(settings.getString("DEF_LANG", ""));
        Locale.setDefault(locale);
    }
    Configuration config = new Configuration();
    config.locale = locale;
    context.getResources().updateConfiguration(config, null);
}

From source file:ch.ralscha.extdirectspring_itest.UserServiceTest.java

@Test
public void testPostWithErrors() throws IOException {
    Locale.setDefault(Locale.ENGLISH);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("extTID", "2"));
    formparams.add(new BasicNameValuePair("extAction", "userService"));
    formparams.add(new BasicNameValuePair("extMethod", "updateUser"));
    formparams.add(new BasicNameValuePair("extType", "rpc"));
    formparams.add(new BasicNameValuePair("extUpload", "false"));
    formparams.add(new BasicNameValuePair("name", "Joe"));
    formparams.add(new BasicNameValuePair("age", "30"));
    UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formparams, "UTF-8");

    this.post.setEntity(postEntity);

    CloseableHttpResponse response = this.client.execute(this.post);
    try {/* w  ww .j  a  va2  s.c o m*/
        HttpEntity entity = response.getEntity();
        assertThat(entity).isNotNull();
        String responseString = EntityUtils.toString(entity);

        Map<String, Object> rootAsMap = this.mapper.readValue(responseString, Map.class);
        assertThat(rootAsMap).hasSize(5);
        assertThat(rootAsMap.get("method")).isEqualTo("updateUser");
        assertThat(rootAsMap.get("type")).isEqualTo("rpc");
        assertThat(rootAsMap.get("action")).isEqualTo("userService");
        assertThat(rootAsMap.get("tid")).isEqualTo(2);

        Map<String, Object> result = (Map<String, Object>) rootAsMap.get("result");
        assertThat(result).hasSize(4);
        assertThat(result.get("name")).isEqualTo("Joe");
        assertThat(result.get("age")).isEqualTo(30);
        assertThat(result.get("success")).isEqualTo(Boolean.FALSE);

        Map<String, Object> errors = (Map<String, Object>) result.get("errors");
        assertThat(errors).hasSize(1);
        assertThat((List<String>) errors.get("email")).containsOnly("may not be empty");
    } finally {
        IOUtils.closeQuietly(response);
    }
}

From source file:ch.ralscha.extdirectspring_itest.UserControllerTest.java

@Test
public void testPostWithErrors() throws IOException {
    Locale.setDefault(Locale.ENGLISH);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("extTID", "2"));
    formparams.add(new BasicNameValuePair("extAction", "userController"));
    formparams.add(new BasicNameValuePair("extMethod", "updateUser"));
    formparams.add(new BasicNameValuePair("extType", "rpc"));
    formparams.add(new BasicNameValuePair("extUpload", "false"));
    formparams.add(new BasicNameValuePair("name", "Joe"));
    formparams.add(new BasicNameValuePair("age", "30"));
    UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formparams, "UTF-8");

    this.post.setEntity(postEntity);

    CloseableHttpResponse response = this.client.execute(this.post);
    try {//w w w.j av  a 2s  .  com
        HttpEntity entity = response.getEntity();
        assertThat(entity).isNotNull();
        String responseString = EntityUtils.toString(entity);

        Map<String, Object> rootAsMap = this.mapper.readValue(responseString, Map.class);
        assertThat(rootAsMap).hasSize(5);
        assertThat(rootAsMap.get("method")).isEqualTo("updateUser");
        assertThat(rootAsMap.get("type")).isEqualTo("rpc");
        assertThat(rootAsMap.get("action")).isEqualTo("userController");
        assertThat(rootAsMap.get("tid")).isEqualTo(2);

        Map<String, Object> result = (Map<String, Object>) rootAsMap.get("result");
        assertThat(result).hasSize(4);
        assertThat(result.get("name")).isEqualTo("Joe");
        assertThat(result.get("age")).isEqualTo(30);
        assertThat(result.get("success")).isEqualTo(Boolean.FALSE);

        Map<String, Object> errors = (Map<String, Object>) result.get("errors");
        assertThat(errors).hasSize(1);
        assertThat((List<String>) errors.get("email")).containsOnly("may not be empty");
    } finally {
        IOUtils.closeQuietly(response);
    }
}

From source file:net.sf.dynamicreports.test.jasper.chart.AreaChartTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<String> column1;
    TextColumnBuilder<Integer> column2;

    Locale.setDefault(Locale.ENGLISH);

    rb.columns(column1 = col.column("Column1", "field1", String.class),
            column2 = col.column("Column2", "field2", Integer.class))
            .summary(cht.areaChart().setCategory(column1).series(cht.serie(column2))
                    .setCategoryAxisFormat(cht.axisFormat().setLabel("category").setLabelColor(Color.BLUE)
                            .setLabelFont(stl.fontArialBold()).setTickLabelFont(stl.fontArial().setItalic(true))
                            .setTickLabelColor(Color.CYAN).setTickLabelRotation(45d)
                            .setLineColor(Color.LIGHT_GRAY)),
                    cht.areaChart().setCategory(column1).series(cht.serie(column2))
                            .setValueAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00")
                                    .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1)
                                    .setRangeMaxValueExpression(15)));
}