List of usage examples for java.text DecimalFormatSymbols setGroupingSeparator
public void setGroupingSeparator(char groupingSeparator)
From source file:CommonServlets.EditUser.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = null, userName = null, job = null, address = null, password = null, img = null, role = null; BigDecimal creditLimit = new BigDecimal(0); try {//from w w w . j av a2s .c o m // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Parse the request List<FileItem> items = upload.parseRequest(request); Iterator<FileItem> iter = items.iterator(); while (iter.hasNext()) { FileItem item = iter.next(); if (item.isFormField()) { //processFormField(item); String name = item.getFieldName(); String value = item.getString(); if (name.equalsIgnoreCase("email")) { email = value; } else if (name.equalsIgnoreCase("userName")) { userName = value; } else if (name.equalsIgnoreCase("creditLimit")) { DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setGroupingSeparator(','); symbols.setDecimalSeparator('.'); String pattern = "#,##0.0#"; DecimalFormat decimalFormat = new DecimalFormat(pattern, symbols); decimalFormat.setParseBigDecimal(true); creditLimit = (BigDecimal) decimalFormat.parse(value); } else if (name.equalsIgnoreCase("job")) { job = value; } else if (name.equalsIgnoreCase("address")) { address = value; } else if (name.equalsIgnoreCase("password")) { password = value; } } else if (!item.isFormField() && !item.getName().equals("")) { System.out.println(new File(AddProduct.class.getClassLoader().getResource("").getPath() .replace("%20", " ") .substring(0, AddProduct.class.getClassLoader().getResource("").getPath() .replace("%20", " ").length() - 27) + "/web/Resources/users_pics/" + item.getName())); item.write(new File(AddProduct.class.getClassLoader().getResource("").getPath() .replace("%20", " ") .substring(0, AddProduct.class.getClassLoader().getResource("").getPath() .replace("%20", " ").length() - 27) + "/web/Resources/users_pics/" + item.getName())); img = item.getName(); } } User u = new User(email, userName, password, creditLimit, job, address, img, role); controlServlet.editUserDate(u); HttpSession session = request.getSession(true); session.setAttribute("done", "1"); ControlServlet c = new ControlServlet(); User myUser = c.getUser(userName); session.setAttribute("user", myUser); response.sendRedirect("UserHome.jsp"); } catch (Exception ex) { Logger.getLogger(AddProduct.class.getName()).log(Level.SEVERE, null, ex); } }
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 a2s .c o m*/ * * @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:org.dashbuilder.dataprovider.backend.csv.CSVParser.java
protected DecimalFormat getNumberFormat(String columnId) { DecimalFormat format = _numberFormatMap.get(columnId); if (format == null) { DecimalFormatSymbols numberSymbols = new DecimalFormatSymbols(); numberSymbols.setGroupingSeparator(dataSetDef.getNumberGroupSeparator(columnId)); numberSymbols.setDecimalSeparator(dataSetDef.getNumberDecimalSeparator(columnId)); format = new DecimalFormat(dataSetDef.getPattern(columnId), numberSymbols); _numberFormatMap.put(columnId, format); }/*from w ww . j av a2s.com*/ return format; }
From source file:org.jboss.dashboard.dataset.csv.CSVDataSet.java
public CSVDataSet(DataProvider provider, CSVDataLoader loader) { super(provider); this.csvLoader = loader; DecimalFormatSymbols numberSymbols = new DecimalFormatSymbols(); numberSymbols.setGroupingSeparator(csvLoader.getCsvNumberGroupSeparator()); numberSymbols.setDecimalSeparator(csvLoader.getCsvNumberDecimalSeparator()); this._numberFormat = new DecimalFormat("#,##0.00", numberSymbols); this._dateFormat = new SimpleDateFormat(csvLoader.getCsvDatePattern()); }
From source file:org.dashbuilder.dataprovider.csv.CSVParser.java
protected DecimalFormat getNumberFormat(String columnId) { DecimalFormat format = _numberFormatMap.get(columnId); if (format == null) { DecimalFormatSymbols numberSymbols = new DecimalFormatSymbols(); numberSymbols.setGroupingSeparator(dataSetDef.getNumberGroupSeparator(columnId)); numberSymbols.setDecimalSeparator(dataSetDef.getNumberDecimalSeparator(columnId)); format = new DecimalFormat(dataSetDef.getNumberPattern(columnId), numberSymbols); _numberFormatMap.put(columnId, format); }//from ww w . j av a 2 s. c om return format; }
From source file:nl.strohalm.cyclos.entities.accounts.external.filemapping.FileMappingWithFields.java
/** * Returns a converter for amount/*w w w .j a v a 2 s . c o m*/ */ 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:com.cognitivabrasil.repositorio.data.entities.Files.java
@Transient public String getSizeFormatted() { String[] powerOfByte = { "Bytes", "KB", "MB", "GB", "TB" }; if (this.sizeInBytes == null || this.sizeInBytes <= 0) { return "Tamanho no definido"; }/*from ww w . jav a 2s .c o m*/ int potencia = 0; int proxima; boolean testaPotenciaActual; boolean testaPotenciaSeguinte; do { proxima = potencia + 1; testaPotenciaActual = (Math.pow(2L, potencia * 10) <= this.sizeInBytes); testaPotenciaSeguinte = (this.sizeInBytes < Math.pow(2L, proxima * 10)); potencia++; } while (!(testaPotenciaActual && testaPotenciaSeguinte)); potencia--; DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.ENGLISH); otherSymbols.setDecimalSeparator(','); otherSymbols.setGroupingSeparator('.'); DecimalFormat myFormatter = new DecimalFormat("##.#", otherSymbols); return myFormatter.format(this.sizeInBytes / Math.pow(2L, potencia * 10)) + " " + powerOfByte[potencia]; }
From source file:com.haulmont.chile.core.datatypes.impl.NumberDatatype.java
/** * Creates non-localized format./*from w w w . ja va 2 s. co m*/ */ protected NumberFormat createFormat() { if (formatPattern != null) { DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(); if (!StringUtils.isBlank(decimalSeparator)) formatSymbols.setDecimalSeparator(decimalSeparator.charAt(0)); if (!StringUtils.isBlank(groupingSeparator)) formatSymbols.setGroupingSeparator(groupingSeparator.charAt(0)); return new DecimalFormat(formatPattern, formatSymbols); } else { return NumberFormat.getNumberInstance(); } }
From source file:by.creepid.docsreporter.context.DocContextProcessorTest.java
public DocContextProcessorTest() { Locale locale = Locale.getDefault(); decimalFormatter = (DecimalFormat) NumberFormat.getInstance(locale); DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); symbols.setDecimalSeparator(','); symbols.setGroupingSeparator(' '); decimalFormatter.setDecimalFormatSymbols(symbols); dateFormat = new SimpleDateFormat("dd.MM.yyyy"); }
From source file:com.haulmont.chile.core.datatypes.impl.AdaptiveNumberDatatype.java
protected java.text.NumberFormat createLocalizedFormat(Locale locale) { FormatStrings formatStrings = AppBeans.get(FormatStringsRegistry.class).getFormatStrings(locale); if (formatStrings == null) { return createFormat(); }//from www. ja v a2 s . com DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols(); if (!decimalSeparator.equals("")) { formatSymbols.setDecimalSeparator(decimalSeparator.charAt(0)); } if (!groupingSeparator.equals("")) { formatSymbols.setGroupingSeparator(groupingSeparator.charAt(0)); } DecimalFormat format = new DecimalFormat(formatPattern, formatSymbols); setupFormat(format); return format; }