Search in sources :

Example 31 with ChoiceFormat

use of java.text.ChoiceFormat in project j2objc by google.

the class NumberFormatTest method test_setRoundingMode_NullRoundingMode.

public void test_setRoundingMode_NullRoundingMode() {
    try {
        // Create a subclass ChoiceFormat which doesn't support
        // RoundingMode
        ChoiceFormat choiceFormat = new ChoiceFormat("0#Less than one|1#one|1<Between one and two|2<Greater than two");
        ((NumberFormat) choiceFormat).setRoundingMode(null);
        // Follow the behavior of RI
        fail("UnsupportedOperationException expected");
    } catch (UnsupportedOperationException e) {
    // expected
    }
}
Also used : ChoiceFormat(java.text.ChoiceFormat) NumberFormat(java.text.NumberFormat)

Example 32 with ChoiceFormat

use of java.text.ChoiceFormat in project j2objc by google.

the class NumberFormatTest method test_getCurrency.

/**
     * @tests java.text.NumberFormat#getCurrency()
     */
public void test_getCurrency() {
    // Test for method java.util.Currency getCurrency()
    // a subclass that supports currency formatting
    Currency currH = Currency.getInstance("HUF");
    NumberFormat format = NumberFormat.getInstance(new Locale("hu", "HU"));
    assertSame("Returned incorrect currency", currH, format.getCurrency());
    // a subclass that doesn't support currency formatting
    ChoiceFormat cformat = new ChoiceFormat("0#Less than one|1#one|1<Between one and two|2<Greater than two");
    try {
        ((NumberFormat) cformat).getCurrency();
        fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
}
Also used : Locale(java.util.Locale) Currency(java.util.Currency) ChoiceFormat(java.text.ChoiceFormat) NumberFormat(java.text.NumberFormat)

Example 33 with ChoiceFormat

use of java.text.ChoiceFormat in project robovm by robovm.

the class OldNumberFormatTest method test_setCurrencyLjava_util_Currency.

public void test_setCurrencyLjava_util_Currency() {
    // Test for method void setCurrency(java.util.Currency)
    // a subclass that supports currency formatting
    Currency currA = Currency.getInstance("ARS");
    NumberFormat format = NumberFormat.getInstance(new Locale("hu", "HU"));
    format.setCurrency(currA);
    assertSame("Returned incorrect currency", currA, format.getCurrency());
    // a subclass that doesn't support currency formatting
    ChoiceFormat cformat = new ChoiceFormat("0#Less than one|1#one|1<Between one and two|2<Greater than two");
    try {
        ((NumberFormat) cformat).setCurrency(currA);
        fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
    try {
        NumberFormat.getInstance().setCurrency(null);
        fail("NullPointerException was thrown.");
    } catch (NullPointerException npe) {
    //expected
    }
    try {
        NumberFormat.getIntegerInstance().setCurrency(null);
        fail("NullPointerException was thrown.");
    } catch (NullPointerException npe) {
    //expected
    }
}
Also used : Locale(java.util.Locale) Currency(java.util.Currency) ChoiceFormat(java.text.ChoiceFormat) NumberFormat(java.text.NumberFormat)

Aggregations

ChoiceFormat (java.text.ChoiceFormat)33 NumberFormat (java.text.NumberFormat)15 MessageFormat (java.text.MessageFormat)11 Format (java.text.Format)10 DateFormat (java.text.DateFormat)9 DecimalFormat (java.text.DecimalFormat)7 SimpleDateFormat (java.text.SimpleDateFormat)7 DutySchedule (org.opennms.netmgt.config.users.DutySchedule)4 Currency (java.util.Currency)3 Locale (java.util.Locale)3 Vector (java.util.Vector)3 HttpSession (javax.servlet.http.HttpSession)3 FieldPosition (java.text.FieldPosition)2 ParseException (java.text.ParseException)2 RequestDispatcher (javax.servlet.RequestDispatcher)2 Support_MessageFormat (tests.support.Support_MessageFormat)2 ParsePosition (java.text.ParsePosition)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ServletException (javax.servlet.ServletException)1