/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package test.custom_datatype; import java.text.NumberFormat; import java.util.Locale; /** * * @author mr */ public class Money implements Comparable { public Money() { } public Money(Integer amount) { this.amount = amount; } @Override public String toString() { NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.FRANCE); return nf.format((double) (amount / 100)); } //////////////////////////////////////////// // JAVABEANS Integer amount = 0; public Integer getAmount() { return amount; } public void setAmount(Integer amount) { this.amount = amount; } /////////////////////////////////////////// // COMPARABLE IMPLEMENTATION public int compareTo(Money o) { return amount.compareTo(o.getAmount()); } }