List of usage examples for java.text NumberFormat setMaximumIntegerDigits
public void setMaximumIntegerDigits(int newValue)
From source file:mx.edu.um.mateo.inventario.dao.impl.SalidaDaoHibernate.java
private String getFolioTemporal(Almacen almacen) { Query query = currentSession() .createQuery("select f from Folio f where f.nombre = :nombre and f.almacen.id = :almacenId"); query.setString("nombre", "SALIDA-TEMPORAL"); query.setLong("almacenId", almacen.getId()); query.setLockOptions(LockOptions.UPGRADE); Folio folio = (Folio) query.uniqueResult(); if (folio == null) { folio = new Folio("SALIDA-TEMPORAL"); folio.setAlmacen(almacen);/*from w w w . ja v a 2s.c o m*/ currentSession().save(folio); currentSession().flush(); return getFolioTemporal(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("TS-"); 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:mx.edu.um.mateo.inventario.dao.impl.EntradaDaoHibernate.java
private 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", "ENTRADA"); query.setLong("almacenId", almacen.getId()); query.setLockOptions(LockOptions.UPGRADE); Folio folio = (Folio) query.uniqueResult(); if (folio == null) { folio = new Folio("ENTRADA"); folio.setAlmacen(almacen);/*from w ww. j a va 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("E-"); 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:mx.edu.um.mateo.inventario.dao.impl.EntradaDaoHibernate.java
private String getFolioTemporal(Almacen almacen) { Query query = currentSession() .createQuery("select f from Folio f where f.nombre = :nombre and f.almacen.id = :almacenId"); query.setString("nombre", "ENTRADA-TEMPORAL"); query.setLong("almacenId", almacen.getId()); query.setLockOptions(LockOptions.UPGRADE); Folio folio = (Folio) query.uniqueResult(); if (folio == null) { folio = new Folio("ENTRADA-TEMPORAL"); folio.setAlmacen(almacen);/* w ww.j ava2 s . com*/ currentSession().save(folio); currentSession().flush(); return getFolioTemporal(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("TE-"); 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:fr.hoteia.qalingo.core.web.util.impl.RequestUtilImpl.java
/** * *//*from w w w . j a v a 2 s .c om*/ public NumberFormat getNumberFormat(final RequestData requestData, final String currencyCode, final RoundingMode roundingMode, final int maximumFractionDigits, final int minimumFractionDigits, final int maximumIntegerDigits, final int minimumIntegerDigits) throws Exception { final Localization localization = requestData.getLocalization(); final Locale locale = localization.getLocale(); NumberFormat formatter = NumberFormat.getCurrencyInstance(locale); formatter.setGroupingUsed(true); formatter.setParseIntegerOnly(false); formatter.setRoundingMode(roundingMode); Currency currency = Currency.getInstance(currencyCode); formatter.setCurrency(currency); formatter.setMaximumFractionDigits(maximumFractionDigits); formatter.setMinimumFractionDigits(minimumFractionDigits); formatter.setMaximumIntegerDigits(maximumIntegerDigits); formatter.setMinimumIntegerDigits(minimumIntegerDigits); return formatter; }
From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java
private String getFolio(Empresa empresa) { Query query = currentSession().createQuery( "select f from FolioActivo f where f.nombre = :nombre and f.organizacion.id = :organizacionId"); query.setString("nombre", "ACTIVOS"); query.setLong("organizacionId", empresa.getOrganizacion().getId()); query.setLockOptions(LockOptions.UPGRADE); FolioActivo folio = (FolioActivo) query.uniqueResult(); if (folio == null) { folio = new FolioActivo("ACTIVOS"); folio.setOrganizacion(empresa.getOrganizacion()); currentSession().save(folio);// ww w. ja v a 2 s . c o m return getFolio(empresa); } folio.setValor(folio.getValor() + 1); java.text.NumberFormat nf = java.text.DecimalFormat.getInstance(); nf.setGroupingUsed(false); nf.setMinimumIntegerDigits(7); nf.setMaximumIntegerDigits(7); nf.setMaximumFractionDigits(0); StringBuilder sb = new StringBuilder(); sb.append("A-"); sb.append(empresa.getOrganizacion().getCodigo()); sb.append(empresa.getCodigo()); sb.append(nf.format(folio.getValor())); return sb.toString(); }
From source file:de.innovationgate.wga.server.api.WGA.java
/** * Returns an OpenWGA number format// w w w . j a va 2 s . c o m * @param pattern The number format pattern * @param locale A locale to use for locale-dependent number parts. Specify null to let the current WebTML context choose the locale. * @throws WGException */ public NumberFormat getNumberFormat(String pattern, Locale locale) throws WGException { // Select language for language dependent number formats if (locale == null) { locale = chooseLocale(locale); } if (WGUtils.isEmpty(pattern)) { NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); numberFormat.setMaximumFractionDigits(Integer.MAX_VALUE); numberFormat.setMaximumIntegerDigits(Integer.MAX_VALUE); return numberFormat; } // For default pattern if (pattern.toLowerCase().equals("decimal")) { return NumberFormat.getNumberInstance(locale); } // Custom pattern return new DecimalFormat(pattern, new DecimalFormatSymbols(locale)); }
From source file:org.apache.camel.dataformat.bindy.BindyAbstractFactory.java
private static NumberFormat getNumberFormat() { // Get instance of NumberFormat NumberFormat nf = NumberFormat.getInstance(); // set max number of digits to 3 (thousands) nf.setMaximumIntegerDigits(3); nf.setMinimumIntegerDigits(3);//from w w w. j av a2 s.co m return nf; }
From source file:org.apache.cocoon.template.instruction.FormatNumber.java
private void configureFormatter(NumberFormat formatter, Boolean isGroupingUsed, Number maxIntegerDigits, Number minIntegerDigits, Number maxFractionDigits, Number minFractionDigits) { if (isGroupingUsed != null) formatter.setGroupingUsed(isGroupingUsed.booleanValue()); if (maxIntegerDigits != null) formatter.setMaximumIntegerDigits(maxIntegerDigits.intValue()); if (minIntegerDigits != null) formatter.setMinimumIntegerDigits(minIntegerDigits.intValue()); if (maxFractionDigits != null) formatter.setMaximumFractionDigits(maxFractionDigits.intValue()); if (minFractionDigits != null) formatter.setMinimumFractionDigits(minFractionDigits.intValue()); }
From source file:org.apache.hadoop.hive.ql.udf.UDFNumberFormat.java
public String evaluate(DoubleWritable d, IntWritable fracMax, IntWritable fracMin, IntWritable intMax, IntWritable intMin) {/*from w w w .ja v a 2 s . c om*/ if (d == null || fracMax == null || intMax == null) { return null; } if (fracMin == null || intMin == null) { return null; } double ori = d.get(); try { NumberFormat nFormat = NumberFormat.getNumberInstance(); nFormat.setMaximumFractionDigits(fracMax.get()); nFormat.setMaximumIntegerDigits(intMax.get()); nFormat.setMinimumFractionDigits(fracMin.get()); nFormat.setMinimumIntegerDigits(intMin.get()); 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(LongWritable d, IntWritable fracMax, IntWritable fracMin, IntWritable intMax, IntWritable intMin) {// www. j av a 2 s . co m if (d == null || fracMax == null || intMax == null) { return null; } if (fracMin == null || intMin == null) { return null; } long ori = d.get(); try { NumberFormat nFormat = NumberFormat.getNumberInstance(); nFormat.setMaximumFractionDigits(fracMax.get()); nFormat.setMaximumIntegerDigits(intMax.get()); nFormat.setMinimumFractionDigits(fracMin.get()); nFormat.setMinimumIntegerDigits(intMin.get()); nFormat.setGroupingUsed(false); return nFormat.format(ori); } catch (Exception e) { LOG.error("can not format value: " + ori); return null; } }