public final class Coin extends Object implements Monetary, Comparable<Coin>, Serializable
Modifier and Type | Field and Description |
---|---|
static Coin |
CENT
0.01 Bitcoins.
|
static Coin |
COIN
One Bitcoin.
|
static Coin |
FIFTY_COINS |
static Coin |
MICROCOIN
0.000001 Bitcoins, also known as 1 µBTC or 1 uBTC.
|
static Coin |
MILLICOIN
0.001 Bitcoins, also known as 1 mBTC.
|
static Coin |
NEGATIVE_SATOSHI
Represents a monetary value of minus one satoshi.
|
static Coin |
SATOSHI
A satoshi is the smallest unit that can be transferred.
|
static int |
SMALLEST_UNIT_EXPONENT
Number of decimals for one Bitcoin.
|
long |
value
The number of satoshis of this monetary value.
|
static Coin |
ZERO
Zero Bitcoins.
|
Modifier and Type | Method and Description |
---|---|
Coin |
add(Coin value) |
int |
compareTo(Coin other) |
long |
divide(Coin divisor) |
Coin |
divide(long divisor) |
Coin[] |
divideAndRemainder(long divisor) |
boolean |
equals(Object o) |
long |
getValue()
Returns the number of satoshis of this monetary value.
|
int |
hashCode() |
boolean |
isGreaterThan(Coin other)
Returns true if the monetary value represented by this instance is greater than that
of the given other Coin, otherwise false.
|
boolean |
isLessThan(Coin other)
Returns true if the monetary value represented by this instance is less than that
of the given other Coin, otherwise false.
|
boolean |
isNegative()
Returns true if and only if this instance represents a monetary value less than zero,
otherwise false.
|
boolean |
isPositive()
Returns true if and only if this instance represents a monetary value greater than zero,
otherwise false.
|
boolean |
isZero()
Returns true if and only if this instance represents zero monetary value,
otherwise false.
|
long |
longValue()
Returns the number of satoshis of this monetary value.
|
Coin |
multiply(long factor) |
Coin |
negate() |
static Coin |
parseCoin(String str)
Parses an amount expressed in the way humans are used to.
|
Coin |
shiftLeft(int n) |
Coin |
shiftRight(int n) |
int |
signum() |
int |
smallestUnitExponent()
Returns the absolute value of exponent of the value of a "smallest unit" in scientific notation.
|
Coin |
subtract(Coin value) |
String |
toFriendlyString()
Returns the value as a 0.12 type string.
|
String |
toPlainString()
Returns the value as a plain string denominated in BTC.
|
String |
toString() |
static Coin |
valueOf(int coins,
int cents)
Convert an amount expressed in the way humans are used to into satoshis.
|
static Coin |
valueOf(long satoshis) |
public static final int SMALLEST_UNIT_EXPONENT
public static final Coin ZERO
public static final Coin COIN
public static final Coin CENT
public static final Coin MILLICOIN
public static final Coin MICROCOIN
public static final Coin SATOSHI
public static final Coin FIFTY_COINS
public static final Coin NEGATIVE_SATOSHI
public final long value
public static Coin valueOf(long satoshis)
public int smallestUnitExponent()
Monetary
smallestUnitExponent
in interface Monetary
public long getValue()
public static Coin valueOf(int coins, int cents)
public static Coin parseCoin(String str)
This takes string in a format understood by
BigDecimal.BigDecimal(String)
,
for example "0", "1", "0.10", "1.23E3", "1234.5E-5".IllegalArgumentException
- if you try to specify fractional satoshis, or a value out of range.public Coin multiply(long factor)
public Coin divide(long divisor)
public Coin[] divideAndRemainder(long divisor)
public long divide(Coin divisor)
public boolean isPositive()
public boolean isNegative()
public boolean isZero()
public boolean isGreaterThan(Coin other)
public boolean isLessThan(Coin other)
public Coin shiftLeft(int n)
public Coin shiftRight(int n)
public Coin negate()
public long longValue()
value
directly.public String toFriendlyString()
public String toPlainString()
Returns the value as a plain string denominated in BTC. The result is unformatted with no trailing zeroes. For instance, a value of 150000 satoshis gives an output string of "0.0015" BTC
public int compareTo(Coin other)
compareTo
in interface Comparable<Coin>
Copyright © 2014. All rights reserved.