Home | History | Annotate | Download | only in util
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html#License
      3 /*
      4 **********************************************************************
      5 * Copyright (c) 2004-2010, International Business Machines
      6 * Corporation and others.  All Rights Reserved.
      7 **********************************************************************
      8 * Author: Alan Liu
      9 * Created: April 12, 2004
     10 * Since: ICU 3.0
     11 **********************************************************************
     12 */
     13 package com.ibm.icu.util;
     14 
     15 
     16 /**
     17  * An amount of currency, consisting of a Number and a Currency.
     18  * CurrencyAmount objects are immutable.
     19  *
     20  * @see java.lang.Number
     21  * @see Currency
     22  * @author Alan Liu
     23  * @stable ICU 3.0
     24  */
     25 public class CurrencyAmount extends Measure {
     26 
     27     /**
     28      * Constructs a new object given a number and a currency.
     29      * @param number the number
     30      * @param currency the currency
     31      * @stable ICU 3.0
     32      */
     33     public CurrencyAmount(Number number, Currency currency) {
     34         super(number, currency);
     35     }
     36 
     37     /**
     38      * Constructs a new object given a double value and a currency.
     39      * @param number a double value
     40      * @param currency the currency
     41      * @stable ICU 3.0
     42      */
     43     public CurrencyAmount(double number, Currency currency) {
     44         super(new Double(number), currency);
     45     }
     46 
     47     /**
     48      * Constructs a new object given a number and a Java currency.
     49      * @param number the number
     50      * @param currency the currency
     51      * @draft ICU 60
     52      */
     53     public CurrencyAmount(Number number, java.util.Currency currency) {
     54         this(number, Currency.fromJavaCurrency(currency));
     55     }
     56 
     57     /**
     58      * Constructs a new object given a double value and a Java currency.
     59      * @param number a double value
     60      * @param currency the currency
     61      * @draft ICU 60
     62      */
     63     public CurrencyAmount(double number, java.util.Currency currency) {
     64         this(number, Currency.fromJavaCurrency(currency));
     65     }
     66 
     67     /**
     68      * Returns the currency of this object.
     69      * @return this object's Currency
     70      * @stable ICU 3.0
     71      */
     72     public Currency getCurrency() {
     73         return (Currency) getUnit();
     74     }
     75 }
     76