Code example for BigDecimal

Methods: compareTo

0
	} 
 
	public int compareTo(Object o) {
		if (o instanceof MonetaryAmount) {
			// TODO: This would actually require some currency conversion magic 
			return this.getValue().compareTo(((MonetaryAmount) o).getValue());
		} 
		return 0; 
	} 
 
	// ********************** Business Methods ********************** // 
 
	public static MonetaryAmount fromString(String amount, String currencyCode) {
		return new MonetaryAmount(new BigDecimal(amount),
								  Currency.getInstance(currencyCode));
	} 
 
	public static MonetaryAmount convert(MonetaryAmount amount,
										 Currency toConcurrency) {
		// TODO: This requires some conversion magic and is therefore broken 
		return new MonetaryAmount(amount.getValue(), toConcurrency);