Java Code Examples for java.util.Locale#CANADA_FRENCH

The following examples show how to use java.util.Locale#CANADA_FRENCH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerializeTests.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testSerializeBinaryProperty() throws IOException
{
    BinaryProperty prop = new BinaryProperty(Format.JSON.mimetype(),"UTF-8");      
    String out = writeResponse(prop);
    assertTrue("Only show the mimeType",  out.equals("{\"mimeType\":\"application/json\"}"));
    prop = new BinaryProperty(Format.XML.mimetype(),"UTF-8", 45, null);      
    out = writeResponse(prop);
    assertTrue("Type is xml.",  StringUtils.contains(out, "\"mimeType\":\"text/xml\""));
    assertTrue("Size must be serialized.",  StringUtils.contains(out, "\"sizeInBytes\":45"));
    
    prop = new BinaryProperty(Format.XML.mimetype(),"UTF-8", 99, Locale.CANADA_FRENCH);      
    out = writeResponse(prop);
    assertFalse("Locale should not be serialized",  StringUtils.contains(out, "\"locale\""));
    
    //Check binary properties serialize ok as part of a bean.
    Flock flock = new Flock("myflock", 50, null, prop);
    out = writeResponse(flock);
    assertFalse("Locale should not be serialized",  StringUtils.contains(out, "\"locale\""));
    assertTrue("Type is xml.",  StringUtils.contains(out, "\"mimeType\":\"text/xml\""));
    assertTrue("Size must be serialized.",  StringUtils.contains(out, "\"sizeInBytes\":99"));
}
 
Example 2
Source File: MyCourseDetailAdapter.java    From ETSMobile-Android2 with Apache License 2.0 6 votes vote down vote up
public MyCourseDetailAdapter(final Context context, final ListeDesElementsEvaluation courseEvaluation, String cote) {
	super();
	this.courseEvaluation = courseEvaluation;
	this.cote = cote;
	nf_frCA = new DecimalFormat("##,#", new DecimalFormatSymbols(Locale.CANADA_FRENCH));
	nf_enUS = new DecimalFormat("##.#");
	// parse exams results
	for ( ElementEvaluation evaluationElement : courseEvaluation.liste) {
		if(evaluationElement.note !=null){
			if(evaluationElement.ignoreDuCalcul.equals("Non")){
				try {
					final String pond = evaluationElement.ponderation;
					final double value = nf_frCA.parse(pond).doubleValue();
					total += value;
					if(total>100){
						total = 100;
					}
				} catch (final ParseException e) {
				}
			}
		}
	}
	
	ctx = context;
	li = (LayoutInflater) ctx.getSystemService(inflater);
}
 
Example 3
Source File: TodayWidgetProvider.java    From ETSMobile-Android2 with Apache License 2.0 6 votes vote down vote up
private void setAllWidgetsLocale(Context context, String language) {
    Configuration configuration = new Configuration();
    DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    Locale locale;

    if (language.equalsIgnoreCase("en")) {
        locale = Locale.ENGLISH;
    } else if (language.equalsIgnoreCase("fr"))
        locale = Locale.CANADA_FRENCH;
    else
        locale = Locale.getDefault();

    Locale.setDefault(locale);
    configuration.locale = locale;
    context.getResources().updateConfiguration(configuration, displayMetrics);
}
 
Example 4
Source File: UtilTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Unit test for {@link Util#parseLocale(String)} method.
 */
@Test void testParseLocale() {
  Locale[] locales = {
      Locale.CANADA,
      Locale.CANADA_FRENCH,
      Locale.getDefault(),
      Locale.US,
      Locale.TRADITIONAL_CHINESE,
      Locale.ROOT,
  };
  for (Locale locale : locales) {
    assertEquals(locale, Util.parseLocale(locale.toString()));
  }
  // Example locale names in Locale.toString() javadoc.
  String[] localeNames = {
      "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr__MAC"
  };
  for (String localeName : localeNames) {
    assertEquals(localeName, Util.parseLocale(localeName).toString());
  }
}
 
Example 5
Source File: LocaleMappingTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocaleMapping() {
    E e = new E();
    e.l1 = Locale.CANADA_FRENCH;
    e.l2 = Arrays.asList(Locale.GERMANY, Locale.TRADITIONAL_CHINESE);
    e.l3 = new Locale[]{Locale.TRADITIONAL_CHINESE, Locale.FRENCH};

    getDs().save(e);
    final Datastore datastore = getDs();
    e = datastore.find(E.class)
                 .filter(eq("_id", e.id))
                 .first();

    Assert.assertEquals(Locale.CANADA_FRENCH, e.l1);

    Assert.assertEquals(2, e.l2.size());
    Assert.assertEquals(Locale.GERMANY, e.l2.get(0));
    Assert.assertEquals(Locale.TRADITIONAL_CHINESE, e.l2.get(1));

    Assert.assertEquals(2, e.l3.length);
    Assert.assertEquals(Locale.TRADITIONAL_CHINESE, e.l3[0]);
    Assert.assertEquals(Locale.FRENCH, e.l3[1]);

}
 
Example 6
Source File: MLTextTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void setUp()
{
    mlText = new MLText(Locale.CANADA_FRENCH, Locale.CANADA_FRENCH.toString());
    mlText.addValue(Locale.US, Locale.US.toString());
    mlText.addValue(Locale.UK, Locale.UK.toString());
    mlText.addValue(Locale.FRENCH, Locale.FRENCH.toString());
    mlText.addValue(Locale.CHINESE, Locale.CHINESE.toString());
}
 
Example 7
Source File: ExampleUnitTest.java    From android with MIT License 5 votes vote down vote up
@Test
public void testStringLocale() throws Exception {
    Locale[] locales = new Locale[]{
            Locale.CANADA,
            Locale.CANADA_FRENCH,
            Locale.CHINESE,
            Locale.ENGLISH,
            Locale.FRANCE,
            Locale.GERMAN,
            Locale.GERMANY,
            Locale.ITALIAN,
            Locale.ITALY,
            Locale.JAPAN,
            Locale.JAPANESE,
            Locale.KOREA,
            Locale.KOREAN,
            Locale.PRC,
            Locale.ROOT,
            Locale.SIMPLIFIED_CHINESE,
            Locale.TAIWAN,
            Locale.TRADITIONAL_CHINESE,
            Locale.UK,
            Locale.US
    };

    String weightString = null;
    for (Locale locale : locales) {
        try {
            weightString = formatFloatWithOneDot(locale, 55.4f);
            float weight = Float.parseFloat(weightString);
        } catch (NumberFormatException e) {
            System.out.println(locale + ">>>>>" + weightString + ">>>>>>>>>> error");
            continue;
        }
        System.out.println(locale + ">>>>>" + weightString);
    }
}
 
Example 8
Source File: ParameterTypeRegistryTest.java    From cucumber with MIT License 5 votes vote down vote up
@Test
public void parse_decimal_numbers_in_canadian_french() {
    ExpressionFactory factory = new ExpressionFactory(new ParameterTypeRegistry(Locale.CANADA_FRENCH));
    Expression expression = factory.createExpression("{bigdecimal}");

    assertThat(expression.match("1\u00A0000,1").get(0).getValue(), is(new BigDecimal("1000.1")));
    assertThat(expression.match("1\u00A0000\u00A0000,1").get(0).getValue(), is(new BigDecimal("1000000.1")));
    assertThat(expression.match("-1,1").get(0).getValue(), is(new BigDecimal("-1.1")));
    assertThat(expression.match("-,1E1").get(0).getValue(), is(new BigDecimal("-1")));
}
 
Example 9
Source File: G7CollationTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void TestG7Data() {
    Locale locales[] = {
            Locale.US,
            Locale.UK,
            Locale.CANADA,
            Locale.FRANCE,
            Locale.CANADA_FRENCH,
            Locale.GERMANY,
            Locale.JAPAN,
            Locale.ITALY
        };
    int i = 0, j = 0;
    for (i = 0; i < locales.length; i++) {
        Collator myCollation= null;
        RuleBasedCollator tblColl1 = null;
        try {
            myCollation = Collator.getInstance(locales[i]);
            tblColl1 = new RuleBasedCollator(((RuleBasedCollator)myCollation).getRules());
        } catch (Exception foo) {
            warnln("Exception: " + foo.getMessage() +
                  "; Locale : " + locales[i].getDisplayName() + " getRules failed");
            continue;
        }
        for (j = 0; j < FIXEDTESTSET; j++) {
            for (int n = j+1; n < FIXEDTESTSET; n++) {
                doTest(tblColl1, testCases[results[i][j]], testCases[results[i][n]], -1);
            }
        }
        myCollation = null;
    }
}
 
Example 10
Source File: HoraireManager.java    From ETSMobile-Android2 with Apache License 2.0 4 votes vote down vote up
/**
 * Creates/Updates a new calendar on the user's device
 *
 * @param joursRemplacesSelected true if the "Jours remplacés" calendar was selected
 * @param seancesSelected true if the "Séances" calendar was selected
 * @param calPublicSelected true if the "Calendrier public ÉTS" was selected
 * @throws Exception if there is an SQL when checking the replaced days (Jours remplacés)
 */
public void updateCalendar(boolean joursRemplacesSelected, boolean seancesSelected, boolean calPublicSelected) throws Exception {

    DatabaseHelper dbHelper = new DatabaseHelper(context);
    AndroidCalendarManager androidCalendarManager = new AndroidCalendarManager(context);

    androidCalendarManager.deleteCalendar(calendarName);
    androidCalendarManager.createCalendar(calendarName);

    SimpleDateFormat joursRemplacesFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.CANADA_FRENCH);

    if (joursRemplacesSelected) {
        //Inserting JoursRemplaces in local calendar
        ArrayList<JoursRemplaces> listeJoursRemplaces = (ArrayList<JoursRemplaces>) dbHelper.getDao(JoursRemplaces.class).queryForAll();


        for (JoursRemplaces joursRemplaces : listeJoursRemplaces) {
            androidCalendarManager.insertEventInCalendar(calendarName,
                    joursRemplaces.description,
                    joursRemplaces.description,
                    "",
                    joursRemplacesFormatter.parse(joursRemplaces.dateOrigine),
                    joursRemplacesFormatter.parse(joursRemplaces.dateOrigine));
        }
    }

    if (seancesSelected) {
        //Inserting Seances in local calendar
        SimpleDateFormat seancesFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.CANADA_FRENCH);
        ArrayList<Seances> seances = (ArrayList<Seances>) dbHelper.getDao(Seances.class).queryForAll();


        for (Seances seance : seances) {

            androidCalendarManager.insertEventInCalendar(calendarName,
                    seance.descriptionActivite.equals("Examen final") ? "Examen final " + seance.coursGroupe : seance.coursGroupe,
                    seance.libelleCours + " - " + seance.descriptionActivite,
                    seance.local,
                    seancesFormatter.parse(seance.dateDebut),
                    seancesFormatter.parse(seance.dateFin));
        }
    }

    if (calPublicSelected) {
        //Inserting public calendar ETS
        ArrayList<Event> events = (ArrayList<Event>) dbHelper.getDao(Event.class).queryForAll();
        for (Event event : events) {
            androidCalendarManager.insertEventInCalendar(calendarName,
                    event.getTitle(),
                    "",
                    ""
                    ,
                    joursRemplacesFormatter.parse(event.getDateDebut()),
                    joursRemplacesFormatter.parse(event.getDateFin()));
        }
    }
}
 
Example 11
Source File: DefaultTypeAdaptersTest.java    From gson with Apache License 2.0 4 votes vote down vote up
public void testLocaleSerializationWithLanguageCountry() {
  Locale target = Locale.CANADA_FRENCH;
  assertEquals("\"fr_CA\"", gson.toJson(target));
}
 
Example 12
Source File: WrapLocale.java    From jphp with Apache License 2.0 4 votes vote down vote up
@Signature
public static Memory CANADA_FRENCH(Environment env, Memory... args) {
    return new ObjectMemory(new WrapLocale(env, Locale.CANADA_FRENCH));
}