当前位置: 首页>>代码示例>>Java>>正文


Java Currency类代码示例

本文整理汇总了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);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:26,代码来源:AmountFormat.java

示例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); 
    }
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:19,代码来源:PortfolioController.java

示例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;
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:22,代码来源:Market.java

示例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());
}
 
开发者ID:krichter722,项目名称:jscience-amount-jpa,代码行数:16,代码来源:SerializationPersistence.java

示例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);
}
  }
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:8,代码来源:PortfolioController.java

示例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();
}
 
开发者ID:krichter722,项目名称:jscience-amount-jpa,代码行数:61,代码来源:JPAPersistence.java

示例7: PortfolioItemBean

import org.jscience.economics.money.Currency; //导入依赖的package包/类
protected PortfolioItemBean(Currency curr) {
	this.currency = curr;
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:4,代码来源:PortfolioItemBean.java

示例8: setCurrentValue

import org.jscience.economics.money.Currency; //导入依赖的package包/类
public void setCurrentValue(double currentValue) {
    //this.currentValue = currentValue;
	this.currentAmount = Amount.valueOf(currentValue, Currency.getReferenceCurrency());
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:5,代码来源:PortfolioItemBean.java

示例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());
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:7,代码来源:PortfolioItemBean.java

示例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());
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:7,代码来源:PortfolioItemBean.java

示例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());
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:7,代码来源:PortfolioItemBean.java

示例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());
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:7,代码来源:PortfolioItemBean.java

示例13: getCurrency

import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
 * @return the currency
 */
public Currency getCurrency() {
	return currency;
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:7,代码来源:PortfolioItemBean.java

示例14: setCurrency

import org.jscience.economics.money.Currency; //导入依赖的package包/类
/**
 * @param currency the currency to set
 */
public void setCurrency(Currency currency) {
	this.currency = currency;
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:7,代码来源:PortfolioItemBean.java

示例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);
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:7,代码来源:Portfolio.java


注:本文中的org.jscience.economics.money.Currency类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。