1 package org.paneris.bibliomania; 2 3 import java.util.Locale; 4 5 import org.melati.poem.util.StringUtils; 6 import org.paneris.bibliomania.generated.CurrencyBase; 7 import org.paneris.bibliomania.util.BibliomaniaUtil; 8 9 10 public class Currency extends CurrencyBase { 11 public Currency() {} 12 13 public Locale toLocale() { 14 String[] parts = StringUtils.split(getLocale(), '_'); 15 if (parts.length > 2) return new Locale(parts[0], parts[1], parts[2]); 16 if (parts.length > 1) return new Locale(parts[0], parts[1]); 17 return null; 18 } 19 20 public double convertFromUK(double value) { 21 return value * getConversionrate().doubleValue(); 22 } 23 24 public double convertToUK(double value) { 25 return value / getConversionrate().doubleValue(); 26 } 27 28 public String convertFromUKandFormat(double value) { 29 return BibliomaniaUtil.euroFormat(toLocale(),convertFromUK(value)); 30 } 31 32 }