本文整理汇总了Java中org.jscience.economics.money.Currency类的典型用法代码示例。如果您正苦于以下问题:Java Currency类的具体用法?Java Currency怎么用?Java Currency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Currency类属于org.jscience.economics.money包,在下文中一共展示了Currency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import org.jscience.economics.money.Currency; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Appendable format(Amount arg0, Appendable arg1)
throws IOException {
if (arg0.getUnit() instanceof Currency)
return formatMoney(arg0, arg1);
if (arg0.isExact()) {
TypeFormat.format(arg0.getExactValue(), arg1);
arg1.append(' ');
return UnitFormat.getInstance().format(arg0.getUnit(), arg1);
}
double value = arg0.getEstimatedValue();
double error = arg0.getAbsoluteError();
int log10Value = (int) MathLib.floor(MathLib.log10(MathLib
.abs(value)));
int log10Error = (int) MathLib.floor(MathLib.log10(error));
int digits = log10Value - log10Error - 1; // Exact digits.
boolean scientific = (MathLib.abs(value) >= 1E6)
|| (MathLib.abs(value) < 1E-6);
boolean showZeros = true;
TypeFormat.format(value, digits, scientific, showZeros, arg1);
arg1.append(' ');
return UnitFormat.getInstance().format(arg0.getUnit(), arg1);
}
示例2: PortfolioController
import org.jscience.economics.money.Currency; //导入依赖的package包/类
public PortfolioController(Portfolio portfolio, Market market) {
this.props = new Properties(); // TODO i18n, use ResourceBundle or Messages where possible
this.market = market;
this.portfolio = portfolio;
quoteFactory = QuoteManager.getQuoteFactory();
try {
InputStream in = PortfolioController.class.getResourceAsStream
("/currency.properties");
props.load(in);
if (Currency.getReferenceCurrency() != null) {
labelCurrency(Currency.getReferenceCurrency());
}
} catch (IOException ie) {
logger.warn("Error loading properties", ie);
}
}
示例3: Market
import org.jscience.economics.money.Currency; //导入依赖的package包/类
public Market(String symbol, String name, Currency curr,
Map<String, String> markets, Map<String, Object> exchangeRates) {
if (Currency.getReferenceCurrency() == null) {
logger.info("Setting Reference Currency to " +
String.valueOf(curr) + "...");
curr.setExchangeRate(1);
Currency.setReferenceCurrency(curr);
} else {
if (curr.equals(Currency.getReferenceCurrency())) {
logger.info(String.valueOf(curr) + " is the Reference Currency.");
curr.setExchangeRate(1);
}
}
this.name = name;
this.symbol = symbol;
this.currency = curr;
this.knownMarkets = markets;
this.currencyExchangeRates = exchangeRates;
}
示例4: main
import org.jscience.economics.money.Currency; //导入依赖的package包/类
public static void main(String[] args) throws IOException, ClassNotFoundException {
A a = new A(2L, Amount.valueOf(3.0, Currency.EUR));
File outputFile = File.createTempFile("prefix", "suffix");
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
objectOutputStream.writeObject(a);
objectOutputStream.flush();
}
FileInputStream fileInputStream = new FileInputStream(outputFile);
A aReloaded;
try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
aReloaded = (A) objectInputStream.readObject();
}
System.out.println(aReloaded.toString());
}
示例5: labelCurrency
import org.jscience.economics.money.Currency; //导入依赖的package包/类
private void labelCurrency(String symbol, Currency curr) {
//String label = market.getCurrencyLabels().get(cSymbol);
String label = props.getProperty(symbol, "");
if (label != null && label.length()>0) {
UnitFormat.getInstance().label(curr, label);
}
}
示例6: main
import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
String databaseDir = System.getProperty("databaseDir");
File databaseDirFile;
if(databaseDir == null) {
databaseDirFile = File.createTempFile("prefix", "suffix");
databaseDirFile.delete();
databaseDirFile.mkdirs();
}else {
databaseDirFile = new File(databaseDir);
if(!databaseDirFile.exists()) {
databaseDirFile.mkdirs();
}
}
LOGGER.info(String.format("database directory is: %s", databaseDirFile.getAbsolutePath()));
if(!databaseDirFile.exists()) {
databaseDirFile.mkdirs();
}
String databaseName = System.getProperty("databaseName");
//allows resuage of database if databaseName system property is
//specified
File databaseFile;
if(databaseName == null) {
databaseFile = File.createTempFile("prefix", "suffix", databaseDirFile);
databaseFile.delete();
databaseFile.mkdir();
} else {
databaseFile = new File(databaseDirFile, databaseName);
if(!databaseFile.exists()) {
databaseFile.mkdir();
}else if(!databaseFile.isDirectory()) {
throw new IllegalArgumentException();
}
}
String action = System.getProperty("drop", "drop-and-create");
boolean needCreation = !databaseFile.exists() || (databaseFile.exists() && databaseFile.list().length == 0);
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("test", new HashMap() {
{
put("javax.persistence.jdbc.url",
String.format("jdbc:derby:memory:%s%s",
databaseFile.getAbsolutePath(),
needCreation ? ";create=true": ""));
put("javax.persistence.jdbc.user",
"sa");
put("javax.persistence.jdbc.driver",
"org.apache.derby.jdbc.EmbeddedDriver");
put("javax.persistence.jdbc.password",
"");
put("javax.persistence.schema-generation.database.action",
action);
}
});
EntityManager entityManager = entityManagerFactory.createEntityManager();
A a = new A(1L, Amount.valueOf(1, Currency.EUR));
entityManager.getTransaction().begin();
entityManager.persist(a);
entityManager.getTransaction().commit();
}
示例7: PortfolioItemBean
import org.jscience.economics.money.Currency; //导入依赖的package包/类
protected PortfolioItemBean(Currency curr) {
this.currency = curr;
}
示例8: setCurrentValue
import org.jscience.economics.money.Currency; //导入依赖的package包/类
public void setCurrentValue(double currentValue) {
//this.currentValue = currentValue;
this.currentAmount = Amount.valueOf(currentValue, Currency.getReferenceCurrency());
}
示例9: getQuoteAmount
import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
* @return the Quote value as Amount
*/
public Amount<Money> getQuoteAmount() {
return Amount.valueOf(quote.getValue(), Currency.getReferenceCurrency());
}
示例10: getQuoteChangeAmount
import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
* @return the Quote change as Amount
*/
public Amount<Money> getQuoteChangeAmount() {
return Amount.valueOf(quote.getChange(), Currency.getReferenceCurrency());
}
示例11: getGainLossAmount
import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
* @return Gain or Loss as Amount
*/
public Amount<Money> getGainLossAmount() {
return Amount.valueOf(gainLoss, Currency.getReferenceCurrency());
}
示例12: getQuoteOpenAmount
import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
* @return Quote Opening Price as Amount
*/
public Amount<Money> getQuoteOpenAmount() {
return Amount.valueOf(quote.getOpenPrice(), Currency.getReferenceCurrency());
}
示例13: getCurrency
import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
* @return the currency
*/
public Currency getCurrency() {
return currency;
}
示例14: setCurrency
import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
* @param currency the currency to set
*/
public void setCurrency(Currency currency) {
this.currency = currency;
}
示例15: Portfolio
import org.jscience.economics.money.Currency; //导入依赖的package包/类
public Portfolio(double cashVal, LinkedHashMap<String, String> sharesPerSymbol,
Currency curr) {
this.sharesPerSymbol = sharesPerSymbol;
this.currency = curr;
this.setCash(cashVal);
}