List of usage examples for java.text NumberFormat setGroupingUsed
public void setGroupingUsed(boolean newValue)
From source file:org.jumpmind.vaadin.ui.common.AbstractSpringUI.java
@Override protected void init(VaadinRequest request) { setErrorHandler(new DefaultErrorHandler() { private static final long serialVersionUID = 1L; @Override//from w w w . jav a 2s. c o m public void error(com.vaadin.server.ErrorEvent event) { Throwable ex = event.getThrowable(); CommonUiUtils.notify(ex); if (ex != null) { log.error(ex.getMessage(), ex); } else { log.error("An unexpected error occurred"); } } }); VaadinSession.getCurrent().setConverterFactory(new DefaultConverterFactory() { private static final long serialVersionUID = 1L; @Override protected Converter<Date, ?> createDateConverter(Class<?> sourceType) { return super.createDateConverter(sourceType); } protected Converter<String, ?> createStringConverter(Class<?> sourceType) { if (Double.class.isAssignableFrom(sourceType)) { return new StringToDoubleConverter(); } else if (Float.class.isAssignableFrom(sourceType)) { return new StringToFloatConverter(); } else if (Integer.class.isAssignableFrom(sourceType)) { return new StringToIntegerConverter() { private static final long serialVersionUID = 1L; @Override protected NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; } }; } else if (Long.class.isAssignableFrom(sourceType)) { return new StringToLongConverter() { private static final long serialVersionUID = 1L; @Override protected NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; } }; } else if (BigDecimal.class.isAssignableFrom(sourceType)) { return new StringToBigDecimalConverter(); } else if (Boolean.class.isAssignableFrom(sourceType)) { return new StringToBooleanConverter(); } else if (Date.class.isAssignableFrom(sourceType)) { return new StringToDateConverter(); } else { return null; } } }); Responsive.makeResponsive(this); }
From source file:com.jaspersoft.studio.editor.preview.input.BigNumericInput.java
public void updateInput() { if (num.isDisposed()) return;//ww w . j av a2 s .com Object value = params.get(param.getName()); if (value != null && value instanceof String) value = getNumber((String) value); if (value != null && value instanceof Number) { NumberFormat nformat = NumberFormat.getInstance(Locale.US); nformat.setGroupingUsed(false); num.setText(nformat.format(value)); } else num.setText(""); setDecoratorNullable(param); }
From source file:mx.edu.um.mateo.inventario.dao.impl.CancelacionDaoHibernate.java
@Override public String getFolio(Almacen almacen) { Query query = currentSession() .createQuery("select f from Folio f where f.nombre = :nombre and f.almacen.id = :almacenId"); query.setString("nombre", "CANCELACION"); query.setLong("almacenId", almacen.getId()); query.setLockOptions(LockOptions.UPGRADE); Folio folio = (Folio) query.uniqueResult(); if (folio == null) { folio = new Folio("CANCELACION"); folio.setAlmacen(almacen);// www . j a v a 2 s.co m currentSession().save(folio); return getFolio(almacen); } folio.setValor(folio.getValor() + 1); java.text.NumberFormat nf = java.text.DecimalFormat.getInstance(); nf.setGroupingUsed(false); nf.setMinimumIntegerDigits(9); nf.setMaximumIntegerDigits(9); nf.setMaximumFractionDigits(0); StringBuilder sb = new StringBuilder(); sb.append("C-"); sb.append(almacen.getEmpresa().getOrganizacion().getCodigo()); sb.append(almacen.getEmpresa().getCodigo()); sb.append(almacen.getCodigo()); sb.append(nf.format(folio.getValor())); return sb.toString(); }
From source file:au.org.emii.geoserver.wfs.response.RestrictedColumnCsvOutputFormat.java
private NumberFormat getCoordFormatter() { NumberFormat coordFormatter = NumberFormat.getInstance(Locale.US); coordFormatter.setMaximumFractionDigits(getInfo().getGeoServer().getSettings().getNumDecimals()); coordFormatter.setGroupingUsed(false); return coordFormatter; }
From source file:org.apache.hadoop.hive.ql.udf.UDFNumberFormat.java
public String evaluate(DoubleWritable d) { if (d == null) { return null; }/* w w w. j a v a 2s.co m*/ double ori = d.get(); try { NumberFormat nFormat = NumberFormat.getNumberInstance(); nFormat.setMaximumFractionDigits(maxdefault); nFormat.setMaximumIntegerDigits(maxdefault); nFormat.setGroupingUsed(false); return nFormat.format(ori); } catch (Exception e) { LOG.error("can not format value: " + ori); return null; } }
From source file:org.apache.hadoop.hive.ql.udf.UDFNumberFormat.java
public String evaluate(DoubleWritable d, IntWritable fracMax, IntWritable intMax) { if (d == null || fracMax == null || intMax == null) { return null; }//from www . j a v a 2 s .c om double ori = d.get(); try { NumberFormat nFormat = NumberFormat.getNumberInstance(); nFormat.setMaximumFractionDigits(fracMax.get()); nFormat.setMaximumIntegerDigits(intMax.get()); nFormat.setGroupingUsed(false); return nFormat.format(ori); } catch (Exception e) { LOG.error("can not format value: " + ori); return null; } }
From source file:org.hoteia.qalingo.core.domain.CurrencyReferential.java
public NumberFormat getEcoCurrencyformat() { NumberFormat formatter = getStandardCurrencyformat(); formatter.setGroupingUsed(true); formatter.setParseIntegerOnly(false); formatter.setRoundingMode(RoundingMode.HALF_EVEN); formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(2); formatter.setMaximumIntegerDigits(1000000); formatter.setMinimumIntegerDigits(1); return formatter; }
From source file:org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReducePOStoreImpl.java
private String getPartName(JobConf conf) { int partition = conf.getInt("mapred.task.partition", -1); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumIntegerDigits(5); numberFormat.setGroupingUsed(false); return "part-" + numberFormat.format(partition); }
From source file:org.netxilia.functions.TextFunctions.java
public String FIXED(double number, int decimals, boolean no_thousands_separator) { NumberFormat format = NumberFormat.getInstance(); format.setMaximumFractionDigits(decimals); format.setGroupingUsed(!no_thousands_separator); return format.format(number); }
From source file:escuela.AlumnoDaoTest.java
/** * Test of lista method, of class AlumnoDao. *//*from w w w. ja va 2s . c om*/ @Test public void debieraObtenerListaDeAlumnos() { log.debug("lista"); NumberFormat nf = DecimalFormat.getInstance(); NumberFormat nf2 = DecimalFormat.getInstance(); nf.setMinimumIntegerDigits(4); nf.setGroupingUsed(false); nf2.setMinimumIntegerDigits(2); for (int i = 1; i <= 10; i++) { StringBuilder sb = new StringBuilder(); sb.append("Alumno").append(nf2.format(i)); Alumno alumno = new Alumno(nf.format(i), sb.toString(), sb.toString()); instance.crea(alumno); } List<Alumno> result = instance.lista(); assertNotNull(result); assertEquals(10, result.size()); }