List of usage examples for java.util Currency getInstance
public static Currency getInstance(Locale locale)
Currency
instance for the country of the given locale. From source file:de.jfachwert.bank.Waehrung.java
/** * Ermittelt aus dem uebergebenen String die entsprechende * {@link Currency}./* w w w .ja v a 2 s . c o m*/ * * @param name z.B. "EUR" oder auch ein einzelnes Symbol * @return die entsprechende Waehrung */ public static Currency toCurrency(String name) { try { return Currency.getInstance(name); } catch (IllegalArgumentException iae) { if (name.length() <= 3) { for (Currency c : Currency.getAvailableCurrencies()) { if (matchesCurrency(name, c)) { return c; } } } throw new IllegalArgumentException("cannot get currency for '" + name + "'", iae); } }
From source file:ch.aonyx.broker.ib.api.contract.Contract.java
public Currency getCurrency() { return Currency.getInstance(currencyCode); }
From source file:net.rrm.ehour.config.EhourConfigJdbc.java
@Override public String getCurrencySymbol() { return Currency.getInstance(getCurrency()).getSymbol(getCurrency()); }
From source file:com.snv.bank.account.AccountControllerTest.java
@Before public void setup() { this.mockMvc = MockMvcBuilders.standaloneSetup(this.accountController).build(); this.account = new Account(); this.account.setId(1234L); this.account.setBankAddress("bank address"); this.account.setBankDeskNumber(1234L); this.account.setBankNumber(5678L); this.account.setAccountNumber(12345678L); this.account.setBankName("Test"); this.account.setBankWebSite("http://www.exemple.com"); this.account.setCurrency(Currency.getInstance(Locale.FRANCE)); User user = new User(); user.setFirstName("toto"); user.setLastName("tata"); user.setEmail("toto.tata@lol.com"); user.setProfile(Profile.ADMIN);//w w w.j a v a 2 s .c om user.setLogin("test"); user.setPassword("pass"); this.account.setUsers(Arrays.asList(user)); }
From source file:org.gnucash.android.ui.transaction.dialog.TransferFundsDialogFragment.java
public static TransferFundsDialogFragment getInstance(Money transactionAmount, String targetCurrencyCode, OnTransferFundsListener transferFundsListener) { TransferFundsDialogFragment fragment = new TransferFundsDialogFragment(); fragment.mOriginAmount = transactionAmount; fragment.mTargetCurrencyCode = Currency.getInstance(targetCurrencyCode).getCurrencyCode(); fragment.mOnTransferFundsListener = transferFundsListener; return fragment; }
From source file:org.gnucash.android.test.ui.AccountsActivityTest.java
protected void setUp() throws Exception { Context context = getInstrumentation().getTargetContext(); Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); editor.putBoolean(context.getString(R.string.key_first_run), false); editor.commit();//from ww w. j a va 2 s.co m mSolo = new Solo(getInstrumentation(), getActivity()); AccountsDbAdapter adapter = new AccountsDbAdapter(getActivity()); Account account = new Account(DUMMY_ACCOUNT_NAME); account.setUID(DUMMY_ACCOUNT_UID); account.setCurrency(Currency.getInstance(DUMMY_ACCOUNT_CURRENCY_CODE)); adapter.addAccount(account); adapter.close(); //the What's new dialog is usually displayed on first run String dismissDialog = getActivity().getString(R.string.label_dismiss); if (mSolo.waitForText(dismissDialog)) { mSolo.clickOnText(dismissDialog); } }
From source file:org.gnucash.android.test.ui.TransactionsActivityTest.java
@Override protected void setUp() throws Exception { mTransactionTimeMillis = System.currentTimeMillis(); Account account = new Account(DUMMY_ACCOUNT_NAME); account.setUID(DUMMY_ACCOUNT_UID); account.setCurrency(Currency.getInstance(Locale.getDefault())); mTransaction = new Transaction(TRANSACTION_AMOUNT, TRANSACTION_NAME); mTransaction.setAccountUID(DUMMY_ACCOUNT_UID); mTransaction.setDescription("What up?"); mTransaction.setTime(mTransactionTimeMillis); account.addTransaction(mTransaction); Context context = getInstrumentation().getTargetContext(); AccountsDbAdapter adapter = new AccountsDbAdapter(context); long id = adapter.addAccount(account); adapter.close();/*from ww w . j ava2 s . c om*/ assertTrue(id > 0); Intent intent = new Intent(Intent.ACTION_VIEW); intent.putExtra(UxArgument.SELECTED_ACCOUNT_ID, id); setActivityIntent(intent); mSolo = new Solo(getInstrumentation(), getActivity()); }
From source file:to.sparks.mtgox.service.UrlFactory.java
public static String getUrlForCommand(String currencyCode, Command restCommand) throws Exception { StringBuilder url = new StringBuilder(); if (StringUtils.isEmpty(currencyCode) || currencyCode.equalsIgnoreCase("BTC") || currencyMap.containsKey(Currency.getInstance(currencyCode))) { if (apiV1RestMap.containsKey(restCommand)) { if (readOnlyCommands.contains(restCommand)) { url.append(MTGOX_HTTP_API_CACHE_URL); } else { url.append(MTGOX_HTTP_API_URL); }//from www . j a va2 s . com url.append(MTGOX_HTTP_API_VERSION_1); Currency currency = null; try { currency = Currency.getInstance(currencyCode); } catch (IllegalArgumentException ex) { // Sigh. } if (StringUtils.isEmpty(currencyCode) || currencyCode.equalsIgnoreCase("BTC") || !currencyMap.containsKey(currency)) { url.append("generic/"); } else { url.append(currencyMap.get(Currency.getInstance(currencyCode))); } url.append(apiV1RestMap.get(restCommand)); } else if (apiV0RestMap.containsKey(restCommand)) { if (readOnlyCommands.contains(restCommand)) { url.append(MTGOX_HTTP_API_CACHE_URL); } else { url.append(MTGOX_HTTP_API_URL); } url.append(MTGOX_HTTP_API_VERSION_0); url.append(apiV0RestMap.get(restCommand)); } else { throw new Exception("Unknown command: " + restCommand.toString()); } } else { throw new Exception("Unknown currency: " + currencyCode); } return url.toString(); }
From source file:net.rrm.ehour.config.EhourConfigJdbc.java
@Override public String getCurrencyCode() { return Currency.getInstance(getCurrency()).getCurrencyCode(); }
From source file:org.yestech.lib.currency.Money.java
public Money(BigDecimal amount, Locale locale) { validateAmount(amount);//from w ww .ja v a 2 s . c om if (locale == null) { throw new CurrencyException("can't have a null locale"); } this.amount = amount; this.locale = locale; this.curreny = Currency.getInstance(locale); }