rssntn67 / SubscriptionManagementDashboard

A Dashboard for Managing Subscription Service to Magazines.
GNU General Public License v3.0
2 stars 0 forks source link

USE Italian number format #152

Closed rssntn67 closed 3 years ago

rssntn67 commented 3 years ago

Convert Italia nu,ber format in BigDecimal.

getBinder().forField(costoUnitario) .asRequired() .withConverter(new StringToBigDecimalConverter("Conversione in Eur") { /**

rssntn67 commented 3 years ago

Per le tabelle: NumberFormat f = NumberFormat.getNumberInstance(Locale.ITALIAN); f.setMinimumFractionDigits(2); // Always show 2 fraction digits f.setGroupingUsed(true); getGrid().addColumn("costoUnitario", new NumberRenderer(f, "EUR"));

rssntn67 commented 3 years ago

public class PubblicazioneGrid extends SmdGrid {

public PubblicazioneGrid(String gridname) {
    super(new Grid<>(Pubblicazione.class),gridname);
    setColumns("nome", "autore","decodeAttivo","editore","tipo.descrizione",  "abbonamento",
               "pubblicato");

// f.setMinimumFractionDigits(2); // Always show 2 fraction digits // f.setGroupingUsed(true); getGrid().addColumn("costoUnitario", new NumberRenderer(NumberFormat.getCurrencyInstance(getLocalFromISO("EUR")))); setColumnCaption("decodeAttivo", "Attiva");

}

public static Locale getLocalFromISO(String iso4217code){
    Locale toReturn = null;
    for (Locale locale : NumberFormat.getAvailableLocales()) {
        String code = NumberFormat.getCurrencyInstance(locale).
                getCurrency().getCurrencyCode();
        if (iso4217code.equals(code)) {
            toReturn = locale;
            break;
        }
    }
    return toReturn;
}

}

rssntn67 commented 3 years ago

Fixed in master