Example usage for java.text DecimalFormatSymbols DecimalFormatSymbols

List of usage examples for java.text DecimalFormatSymbols DecimalFormatSymbols

Introduction

In this page you can find the example usage for java.text DecimalFormatSymbols DecimalFormatSymbols.

Prototype

public DecimalFormatSymbols() 

Source Link

Document

Create a DecimalFormatSymbols object for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:org.pentaho.di.trans.steps.ldifinput.LDIFInputData.java

public LDIFInputData() {
    super();//from   w ww  . ja v  a2 s .  c  o  m
    nrInputFields = -1;
    thisline = null;
    nextline = null;
    nf = NumberFormat.getInstance();
    df = (DecimalFormat) nf;
    dfs = new DecimalFormatSymbols();
    daf = new SimpleDateFormat();
    dafs = new DateFormatSymbols();

    nr_repeats = 0;
    filenr = 0;

    fr = null;
    zi = null;
    is = null;
    InputLDIF = null;
    recordLDIF = null;
    multiValueSeparator = ",";
    totalpreviousfields = 0;
    readrow = null;
    indexOfFilenameField = -1;
}

From source file:com.aw.core.format.NumberFormatter.java

public NumberFormatter(String formatPattern) {
    DecimalFormatSymbols unusualSymbols = new DecimalFormatSymbols();
    unusualSymbols.setDecimalSeparator('.');
    unusualSymbols.setGroupingSeparator(',');
    this.format = new DecimalFormat(formatPattern, unusualSymbols);
}

From source file:br.com.webbudget.domain.misc.filter.MovementFilter.java

/**
 * Metodo para fazer o parse da nossa criteria em um numero decimal para
 * satisfazer a busca por valor/*from  w w w. j a  v  a2 s  .c  om*/
 *
 * @return o valor formatador em bigdecimal
 *
 * @throws ParseException se houver algum erro na hora do parse
 */
public BigDecimal criteriaToBigDecimal() throws ParseException {

    final DecimalFormatSymbols symbols = new DecimalFormatSymbols();

    symbols.setGroupingSeparator('.');
    symbols.setDecimalSeparator(',');

    DecimalFormat decimalFormat = new DecimalFormat("#,##0.0#", symbols);
    decimalFormat.setParseBigDecimal(true);

    return (BigDecimal) decimalFormat.parse(this.criteria);
}

From source file:com.panet.imeta.trans.steps.getxmldata.GetXMLDataData.java

/**
 * /*  w  w w . ja v  a 2 s .  co m*/
 */
public GetXMLDataData() {
    super();

    thisline = null;
    nextline = null;
    nf = NumberFormat.getInstance();
    df = (DecimalFormat) nf;
    dfs = new DecimalFormatSymbols();
    daf = new SimpleDateFormat();
    dafs = new DateFormatSymbols();

    nr_repeats = 0;
    previousRow = null;
    filenr = 0;

    fr = null;
    is = null;
    indexOfXmlField = -1;

    nrInputFields = -1;
    PathValue = null;
    tokenStart = "@_";
    tokenEnd = "-";
    nodenr = 0;
    nodesize = 0;
    an = null;
    readrow = null;
    totalpreviousfields = 0;
    prunePath = "";
    stopPruning = false;
    errorInRowButContinue = false;
}

From source file:org.gbif.ipt.struts2.converter.CoordinateFormatConverter.java

@Override
public Object convertFromString(Map context, String[] values, Class toClass) {
    // The null value is needed to validate in EmlValidator.java class
    if (values[0].length() == 0) {
        return null;
    }/*from   w  ww  . j  a va  2  s  .co m*/
    // The full name of the property which call the method contained in the Map context
    Object coordObject = context.get(ANGLE);
    // The latitude is validating in a range of doubles
    // validate coordinates in case the action context doesn't work properly.
    if (coordObject == null) {
        throw new TypeConversionException("Invalid decimal number: " + values[0]);
    } else {
        String coordinate = context.get(ANGLE).toString();
        // Assign the values of the range depending the property who calls the method.
        Range<Double> range;
        if (coordinate.equals(CoordinateUtils.LATITUDE)) {
            // The range of the latitude coordinate. (-90,90)
            range = Range.between(CoordinateUtils.MIN_LATITUDE, CoordinateUtils.MAX_LATITUDE);
        } else {
            // The range of the longitude coordinate. (-180,180)
            range = Range.between(CoordinateUtils.MIN_LONGITUDE, CoordinateUtils.MAX_LONGITUDE);
        }

        Double number;
        try {
            // Converts String to double if fails throws a NumberFormatException.
            // If the String contains a comma, a character, it throws the exception.
            number = Double.parseDouble(values[0]);
            // If the value is in the range, returns the double.
            if (range.contains(number)) {
                return number;
            } else {
                throw new TypeConversionException("Invalid decimal number: " + values[0]);
            }
        } catch (NumberFormatException e) {
            // Creating a pattern which will convert the comma to period
            // It will return a ParseException if the format was wrong.
            DecimalFormatSymbols symbols = new DecimalFormatSymbols();
            symbols.setDecimalSeparator(ALTERNATIVE_DECIMAL_SEPARATOR);
            DecimalFormat decimal = new DecimalFormat(DECIMAL_PATTERN, symbols);
            try {
                number = decimal.parse(values[0]).doubleValue();
                if (range.contains(number)) {
                    return number;
                } else {
                    throw new TypeConversionException("Invalid decimal number: " + values[0]);
                }
            } catch (ParseException e1) {
                throw new TypeConversionException("Invalid decimal number: " + values[0]);
            }
        }
    }
}

From source file:org.pentaho.di.trans.steps.getxmldata.GetXMLDataData.java

/**
 *
 *///from w  w  w  . j ava2s.c  o m
public GetXMLDataData() {
    super();

    thisline = null;
    nextline = null;
    nf = NumberFormat.getInstance();
    df = (DecimalFormat) nf;
    dfs = new DecimalFormatSymbols();
    daf = new SimpleDateFormat();
    dafs = new DateFormatSymbols();

    nr_repeats = 0;
    previousRow = null;
    filenr = 0;

    fr = null;
    is = null;
    indexOfXmlField = -1;

    nrInputFields = -1;
    PathValue = null;
    tokenStart = "@_";
    tokenEnd = "-";
    nodenr = 0;
    nodesize = 0;
    an = null;
    readrow = null;
    totalpreviousfields = 0;
    prunePath = "";
    stopPruning = false;
    errorInRowButContinue = false;
    nrReadRow = 0;
}

From source file:nl.strohalm.cyclos.entities.accounts.external.filemapping.FileMappingWithFields.java

/**
 * Returns a converter for amount/* w  ww  . j  a va 2 s.  com*/
 */
public Converter<BigDecimal> getNumberConverter() {
    if (numberFormat == NumberFormat.FIXED_POSITION) {
        return new FixedLengthNumberConverter<BigDecimal>(BigDecimal.class, decimalPlaces);
    } else {
        final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setDecimalSeparator(decimalSeparator);
        symbols.setGroupingSeparator('!');

        final DecimalFormat format = new DecimalFormat("0." + StringUtils.repeat("0", decimalPlaces), symbols);
        format.setGroupingUsed(false);
        return new NumberConverter<BigDecimal>(BigDecimal.class, format);
    }
}

From source file:oracle.cubist.datasetBuilder.CubistDatasetBuilder.java

protected double parseDoubleFromCsv(String s) {
    /*try {/*  w  w w .j a va2 s.  co  m*/
    double ret = Double.parseDouble(s);
    System.out.println("Safely parsed "+s+" into "+ret);
    return ret;
    } catch (NumberFormatException n) {     */
    log.trace("Double.parseDouble failed on " + s);
    DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setDecimalSeparator(',');
    DecimalFormat dcf = new DecimalFormat();
    dcf.setDecimalFormatSymbols(symbols);
    try {
        double ret = dcf.parse(s).doubleValue();
        log.trace("Parsed " + s + " into " + dcf.parse(s).doubleValue());
        return ret;
    } catch (ParseException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        throw new RuntimeException("ciao");
    }
    //}
}

From source file:ub.botiga.ServletDispatcher.java

private void showCistell(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession();
    User u = (User) session.getAttribute("user");
    if (u == null) {
        response.sendRedirect("/Botiga/");
        return;/*from w ww .jav a  2 s  .c om*/
    }

    HashMap<String, Product> cistell = getCistell(request);
    HashMap<String, Product> historial = u.getProducts();
    for (Product p : historial.values()) {
        cistell.remove(p.getName());
    }
    session.setAttribute("cistell", cistell);
    if (u.getCredits() - getPreuCistell(request) < 0) {
        request.setAttribute("creditsuficient", false);
    } else {
        request.setAttribute("creditsuficient", true);
    }

    request.setAttribute("cistell", cistell.values());
    DecimalFormat df = new DecimalFormat();
    df.setMaximumFractionDigits(2);
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    dfs.setDecimalSeparator('.');

    df.setDecimalFormatSymbols(dfs);
    request.setAttribute("preucistell", df.format(getPreuCistell(request)));
    showPage(request, response, "cistell.jsp");
}

From source file:tools.help.java

/**
 * vlozi hodnotu to text fildu a upravi jej pocet des miest
 *
 * @param Y text field vstup//from  w  w  w  .j  ava2 s .  co  m
 * @param input value ktoru chem zobrazit v textfielde
 * @param pocetDesMiest pocet desatinnich miest na ktore bude zaukruhlovat
 * cislo
 */
public static void DisplayDouble(javax.swing.JTextField Y, double input, int pocetDesMiest) {

    String symbol = "###.";
    for (int cl0 = 0; cl0 < pocetDesMiest; cl0++) {
        symbol = symbol + "#";
    }

    DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols();
    otherSymbols.setDecimalSeparator('.');
    DecimalFormat df = new DecimalFormat(symbol, otherSymbols); // definovany po?et desatinnych miest
    Y.setText(df.format(input));

}