Package java.util

Examples of java.util.Currency$CurrencyNameGetter


{

  public void test(TestHarness harness)
  {
    NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.UK);
    Currency cur = Currency.getInstance(Locale.UK);
    harness.check(nf.format(2.50).startsWith(cur.getSymbol()),
      nf.format(2.50) + " begins with " + cur.getSymbol());
    Currency newCur = Currency.getInstance("EUR");
    nf.setCurrency(newCur);
    harness.check(nf.format(2.50).startsWith(newCur.getSymbol()),
      nf.format(2.50) + " begins with " + newCur.getSymbol());
  }
View Full Code Here


  private static final String NON_LOCAL_CURRENCY_SYMBOL = "US$";
  private static final int FRACTION_DIGITS = 2;

  public void test(TestHarness harness)
  {
    Currency currency;

    /* Get an instance of the UK currency */
    currency = Currency.getInstance(TEST_LOCALE);
    /* Check for the correct currency code */
    harness.check(currency.getCurrencyCode(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
                  currency.getCurrencyCode() + ").");
    /* Check for the correct currency symbol from within the U.S. */
    harness.check(currency.getSymbol(Locale.US), CURRENCY_SYMBOL, "Currency symbol retrieval check (" +
                  currency.getSymbol(Locale.US) + ").");
    /* Check for the correct currency symbol using another locale */
    harness.check(currency.getSymbol(Locale.CANADA), NON_LOCAL_CURRENCY_SYMBOL, "Non local currency symbol retrieval check (" +
                  currency.getSymbol(Locale.CANADA) + ").");
    /* Check for the correct fraction digits */
    harness.check(currency.getDefaultFractionDigits(), FRACTION_DIGITS, "Currency fraction digits retrieval check (" +
                  currency.getDefaultFractionDigits() + ").");
    /* Check for the correct currency code from toString()*/
    harness.check(currency.toString(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
                  currency.toString() + ").");
  }
View Full Code Here

  private static final int EURO_CHANGE_MONTH = 0;
  private static final int EURO_CHANGE_DATE = 1;

  public void test(TestHarness harness)
  {
    Currency currency;
    Calendar calendar;
    Calendar euroCalendar;

    /* Set default Locale for the JVM */
    Locale.setDefault(TEST_LOCALE);
    /* Get an instance of the currency */
    currency = Currency.getInstance(TEST_LOCALE);
    /* Get the current time in the locale */
    calendar = Calendar.getInstance(TEST_LOCALE);
    /* Get the Euro change-over time in the locale */
    euroCalendar = Calendar.getInstance(TEST_LOCALE);
    euroCalendar.set(EURO_CHANGE_YEAR, EURO_CHANGE_MONTH, EURO_CHANGE_DATE);
    /* Do different comparisons depending on the state of change to the Euro */
    if (calendar.after(euroCalendar))
      {
        /* Check for the correct currency code */
        harness.check(currency.getCurrencyCode(),EURO_ISO4217_CODE, "Euro ISO 4217 currency code retrieval check (" +
                      currency.getCurrencyCode() + ").");
        /* Check for the correct currency symbol */
        harness.check(currency.getSymbol(), EURO_CURRENCY_SYMBOL, "Euro currency symbol retrieval check (" +
                      currency.getSymbol() + ").");
        /* Check for the correct fraction digits */
        harness.check(currency.getDefaultFractionDigits(), EURO_FRACTION_DIGITS,
                      "Euro currency fraction digits retrieval check (" + currency.getDefaultFractionDigits() + ").");
        /* Check for the correct currency code from toString()*/
        harness.check(currency.toString(),EURO_ISO4217_CODE, "Euro ISO 4217 currency code retrieval check (" +
                      currency.toString() + ").");
      }
    else
      {
          /* Check for the correct currency code */
          harness.check(currency.getCurrencyCode(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
                        currency.getCurrencyCode() + ").");
          /* Check for the correct currency symbol */
          harness.check(currency.getSymbol(), CURRENCY_SYMBOL, "Currency symbol retrieval check (" +
                        currency.getSymbol() + ").");
          /* Check for the correct fraction digits */
          harness.check(currency.getDefaultFractionDigits(), FRACTION_DIGITS, "Currency fraction digits retrieval check (" +
                        currency.getDefaultFractionDigits() + ").");
          /* Check for the correct currency code from toString()*/
          harness.check(currency.toString(),ISO4217_CODE, "ISO 4217 currency code retrieval check ("
                        + currency.toString() + ").");
      }
  }
View Full Code Here

  private static final int EURO_CHANGE_MONTH = 0;
  private static final int EURO_CHANGE_DATE = 1;

  public void test(TestHarness harness)
  {
    Currency currency;
    Calendar calendar;
    Calendar euroCalendar;

    /* Set default Locale for the JVM */
    Locale.setDefault(TEST_LOCALE);
    /* Get an instance of the currency */
    currency = Currency.getInstance(TEST_LOCALE);
    /* Get the current time in the locale */
    calendar = Calendar.getInstance(TEST_LOCALE);
    /* Get the Euro change-over time in the locale */
    euroCalendar = Calendar.getInstance(TEST_LOCALE);
    euroCalendar.set(EURO_CHANGE_YEAR, EURO_CHANGE_MONTH, EURO_CHANGE_DATE);
    /* Do different comparisons depending on the state of change to the Euro */
    if (calendar.after(euroCalendar))
      {
        /* Check for the correct currency code */
        harness.check(currency.getCurrencyCode(),EURO_ISO4217_CODE, "Euro ISO 4217 currency code retrieval check (" +
                      currency.getCurrencyCode() + ").");
        /* Check for the correct currency symbol */
        harness.check(currency.getSymbol(), EURO_CURRENCY_SYMBOL, "Euro currency symbol retrieval check (" +
                      currency.getSymbol() + ").");
        /* Check for the correct fraction digits */
        harness.check(currency.getDefaultFractionDigits(), EURO_FRACTION_DIGITS,
                      "Euro currency fraction digits retrieval check (" + currency.getDefaultFractionDigits() + ").");
        /* Check for the correct currency code from toString()*/
        harness.check(currency.toString(),EURO_ISO4217_CODE, "Euro ISO 4217 currency code retrieval check (" +
                      currency.toString() + ").");
      }
    else
      {
          /* Check for the correct currency code */
          harness.check(currency.getCurrencyCode(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
                        currency.getCurrencyCode() + ").");
          /* Check for the correct currency symbol */
          harness.check(currency.getSymbol(), CURRENCY_SYMBOL, "Currency symbol retrieval check (" +
                        currency.getSymbol() + ").");
          /* Check for the correct fraction digits */
          harness.check(currency.getDefaultFractionDigits(), FRACTION_DIGITS, "Currency fraction digits retrieval check (" +
                        currency.getDefaultFractionDigits() + ").");
          /* Check for the correct currency code from toString()*/
          harness.check(currency.toString(),ISO4217_CODE, "ISO 4217 currency code retrieval check ("
                        + currency.toString() + ").");
      }
  }
View Full Code Here

  private static final String CURRENCY_SYMBOL = "\uFFE5";
  private static final int FRACTION_DIGITS = 2;

  public void test(TestHarness harness)
  {
    Currency currency;

    /* Set default Locale for the JVM */
    Locale.setDefault(TEST_LOCALE);
    /* Get an instance of the currency */
    currency = Currency.getInstance(TEST_LOCALE);
    /* Check for the correct currency code */
    harness.check(currency.getCurrencyCode(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
                  currency.getCurrencyCode() + ").");
    /* Check for the correct currency symbol */
    harness.check(currency.getSymbol(), CURRENCY_SYMBOL, "Currency symbol retrieval check (" +
                  currency.getSymbol() + ").");
    /* Check for the correct fraction digits */
    harness.check(currency.getDefaultFractionDigits(), FRACTION_DIGITS, "Currency fraction digits retrieval check (" +
                  currency.getDefaultFractionDigits() + ").");
    /* Check for the correct currency code from toString()*/
    harness.check(currency.toString(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" + currency.toString() + ").");
  }
View Full Code Here

  private static final String UK_CURRENCY_CODE = "GBP";

  public void test(TestHarness harness)
  {
    Currency currency1;
    Currency currency2;
    boolean threwException;

    /* Get a UK Currency instance */
    currency1 = Currency.getInstance(Locale.UK);
    /* And another */
 
View Full Code Here

  private static final String CURRENCY_SYMBOL = "$";
  private static final int FRACTION_DIGITS = 2;

  public void test(TestHarness harness)
  {
    Currency currency;

    /* Set default Locale for the JVM */
    Locale.setDefault(TEST_LOCALE);
    /* Get an instance of the currency */
    currency = Currency.getInstance(TEST_LOCALE);
    /* Check for the correct currency code */
    harness.check(currency.getCurrencyCode(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
                  currency.getCurrencyCode() + ").");
    /* Check for the correct currency symbol */
    harness.check(currency.getSymbol(), CURRENCY_SYMBOL, "Currency symbol retrieval check (" +
                  currency.getSymbol() + ").");
    /* Check for the correct fraction digits */
    harness.check(currency.getDefaultFractionDigits(), FRACTION_DIGITS, "Currency fraction digits retrieval check (" +
                  currency.getDefaultFractionDigits() + ").");
    /* Check for the correct currency code from toString()*/
    harness.check(currency.toString(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" + currency.toString() + ").");
  }
View Full Code Here

  private static final String CURRENCY_SYMBOL = "\uFFE5";
  private static final int FRACTION_DIGITS = 0;

  public void test(TestHarness harness)
  {
    Currency currency;

    /* Set default Locale for the JVM */
    Locale.setDefault(TEST_LOCALE);
    /* Get an instance of the currency */
    currency = Currency.getInstance(TEST_LOCALE);
    /* Check for the correct currency code */
    harness.check(currency.getCurrencyCode(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
                  currency.getCurrencyCode() + ").");
    /* Check for the correct currency symbol */
    harness.check(currency.getSymbol(), CURRENCY_SYMBOL, "Currency symbol retrieval check (" +
                  currency.getSymbol() + ").");
    /* Check for the correct fraction digits */
    harness.check(currency.getDefaultFractionDigits(), FRACTION_DIGITS, "Currency fraction digits retrieval check (" +
                  currency.getDefaultFractionDigits() + ").");
    /* Check for the correct currency code from toString()*/
    harness.check(currency.toString(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" + currency.toString() + ").");
  }
View Full Code Here

  private static final String INVALID_CURRENCY_CODE = "GNU";
  private static final String UK_CURRENCY_CODE = "GBP";

  public void test(TestHarness harness)
  {
    Currency currency;
    boolean threwException;

    /* Check getInstance with a null string */
    threwException = false;
    try
View Full Code Here

        }


        // if still none we will use the default for whatever locale we can get...
        if (iso == null) {
            Currency cur = Currency.getInstance(getLocale(session));
            iso = cur.getCurrencyCode();
        }

        return iso;
    }
View Full Code Here

TOP

Related Classes of java.util.Currency$CurrencyNameGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.