public class Size extends Object
Modifier and Type | Field and Description |
---|---|
static RoundingMode |
DEFAULT_ROUNDING_MODE
default of rounding the number
|
static int |
SIZE_SCALE
default scale of BigDecimal size
|
Constructor and Description |
---|
Size(BigDecimal size,
SizeUnit unit,
SizeUnitType type) |
Modifier and Type | Method and Description |
---|---|
Size |
convertTo(SizeUnit unit)
convert current unit to newUnit
|
Size |
convertTo(SizeUnitType type)
convert current type to newType
|
BigDecimal |
getSize() |
String |
getSizeAsString(int decimalNumber)
get size in string format
|
int |
getSizeInt()
get size with
int value. |
long |
getSizeLong()
get size with
long value. |
SizeUnitType |
getType() |
SizeUnit |
getUnit() |
String |
toString() |
public static int SIZE_SCALE
public static RoundingMode DEFAULT_ROUNDING_MODE
public Size(BigDecimal size, SizeUnit unit, SizeUnitType type)
public BigDecimal getSize()
public int getSizeInt() throws ArithmeticException
int
value.int
valueArithmeticException
- if size
has a nonzero fractional part, or will not fit in an int
public long getSizeLong() throws ArithmeticException
long
value.long
valueArithmeticException
- if size
has a nonzero fractional part, or will not fit in a long
public SizeUnit getUnit()
public SizeUnitType getType()
public Size convertTo(SizeUnitType type)
type
- the new typeSize
public String getSizeAsString(int decimalNumber)
decimalNumber
- number that come after dot(.)Copyright © 2017. All rights reserved.