/** * @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code> */ private static DecimalFormat createIntegerOnlyFormat(String fmt) { DecimalFormatSymbols dsf = DecimalFormatSymbols.getInstance(Locale.ROOT); DecimalFormat result = new DecimalFormat(fmt, dsf); result.setParseIntegerOnly(true); return result; }
/** * @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code> */ private static DecimalFormat createIntegerOnlyFormat(String fmt) { DecimalFormatSymbols dsf = DecimalFormatSymbols.getInstance(Locale.ROOT); DecimalFormat result = new DecimalFormat(fmt, dsf); result.setParseIntegerOnly(true); return result; }
private int determineDepth( String depthString ) throws KettleException { DecimalFormat df = new DecimalFormat( "0" ); ParsePosition pp = new ParsePosition( 0 ); df.setParseIntegerOnly( true ); try { Number n = df.parse( depthString, pp ); if ( n == null ) { return 1; // default } if ( pp.getErrorIndex() == 0 ) { throw new KettleException( "Unable to convert stored depth '" + depthString + "' to depth at position " + pp.getErrorIndex() ); } return n.intValue(); } catch ( Exception e ) { throw new KettleException( "Unable to convert stored depth '" + depthString + "' to depth", e ); } }
/** *Sets if this format will parse, the value part, as integers only. */ public void setParseIntegerOnly(boolean intergerOnley){ format.setParseIntegerOnly(intergerOnley); }
/** * @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code> */ /* package */ static DecimalFormat createIntegerOnlyFormat(String fmt) { DecimalFormat result = new DecimalFormat(fmt); result.setParseIntegerOnly(true); return result; }
/** * @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code> */ /* package */ static DecimalFormat createIntegerOnlyFormat(String fmt) { DecimalFormat result = new DecimalFormat(fmt); result.setParseIntegerOnly(true); return result; }
/** * @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code> */ private static DecimalFormat createIntegerOnlyFormat(String fmt) { DecimalFormatSymbols dsf = DecimalFormatSymbols.getInstance(Locale.ROOT); DecimalFormat result = new DecimalFormat(fmt, dsf); result.setParseIntegerOnly(true); return result; }
/** * @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code> */ private static DecimalFormat createIntegerOnlyFormat(String fmt) { DecimalFormatSymbols dsf = DecimalFormatSymbols.getInstance(Locale.ROOT); DecimalFormat result = new DecimalFormat(fmt, dsf); result.setParseIntegerOnly(true); return result; }
@Override final DecimalFormat getFormatter(String format) { DecimalFormat formatter = super.getFormatter(format); formatter.setParseIntegerOnly(true); return formatter; } }
/** * Since we wish to continue supporting Java 1.3, * for the present we cannot use Java 1.4's * NumberFormat.getIntegerInstance(Locale) method. * This method mimics that method (at least as of JDK1.4.2_01). * It is private so that it can be removed later * without a deprecation period. */ private NumberFormat getIntegerInstance(Locale locale) { DecimalFormat format = (DecimalFormat) NumberFormat.getNumberInstance(locale); format.setMaximumFractionDigits(0); format.setDecimalSeparatorAlwaysShown(false); format.setParseIntegerOnly(true); return format; }
DoubleFormatter(String pattern) { final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); format = new DecimalFormat(pattern, decimalFormatSymbols); format.setParseIntegerOnly(false); format.setParseBigDecimal(false); format.setDecimalSeparatorAlwaysShown(true); }
public DecimalFormatter(String pattern) { final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); format = new DecimalFormat(pattern, decimalFormatSymbols); format.setParseIntegerOnly(false); format.setParseBigDecimal(false); format.setDecimalSeparatorAlwaysShown(true); }
DoubleFormatter(String pattern) { final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); format = new DecimalFormat(pattern, decimalFormatSymbols); format.setParseIntegerOnly(false); format.setParseBigDecimal(false); format.setDecimalSeparatorAlwaysShown(true); }
DoubleFormatter(String pattern) { final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); format = new DecimalFormat(pattern, decimalFormatSymbols); format.setParseIntegerOnly(false); format.setParseBigDecimal(false); format.setDecimalSeparatorAlwaysShown(true); }
DoubleFormatter(String pattern) { final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); format = new DecimalFormat(pattern, decimalFormatSymbols); format.setParseIntegerOnly(false); format.setParseBigDecimal(false); format.setDecimalSeparatorAlwaysShown(true); }
DoubleFormatter(String pattern) { final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); format = new DecimalFormat(pattern, decimalFormatSymbols); format.setParseIntegerOnly(false); format.setParseBigDecimal(false); format.setDecimalSeparatorAlwaysShown(true); }
/** * Le format renvoy permet d'ecrire des entiers sur le meme nombre de caractre. Par exemple <br> * NumberFormat fm=getFormgetFormatForIndexingInteger(5); <br> * String cinq= fm.format(5); //cinq =00005 String quinze=fm.format(15); //quinze=00015 * * @param _nb le nombre d'entier a considrer * @return un format permettant d'ecrire les entiers de 0 a _nb sur le meme nombre de caractres */ public static NumberFormat getFormatForIndexingInteger(final int _nb) { final double log = Math.log(_nb) / Math.log(10); int logf = 0; if (!Double.isInfinite(log) && !Double.isNaN(log)) { logf = ((int) log) + 1; } final DecimalFormat fm = new DecimalFormat(); fm.setMaximumFractionDigits(0); fm.setGroupingUsed(false); fm.setMinimumIntegerDigits(logf); fm.setParseIntegerOnly(true); return fm; }
@Override DecimalFormat getFormatter(String format) { DecimalFormat formatter = super.getFormatter(format); formatter.setParseIntegerOnly(true); formatter.setParseBigDecimal(true); return formatter; } }
private DecimalFormat getDecimalFormat(Locale locale) { DecimalFormat decimalFormat = null; switch (variant) { case INTEGER: decimalFormat = (DecimalFormat)NumberFormat.getNumberInstance(locale); decimalFormat.setMaximumFractionDigits(0); decimalFormat.setDecimalSeparatorAlwaysShown(false); decimalFormat.setParseIntegerOnly(true); break; case NUMBER: decimalFormat = (DecimalFormat)NumberFormat.getNumberInstance(locale); break; case CURRENCY: decimalFormat = (DecimalFormat)NumberFormat.getCurrencyInstance(locale); break; case PERCENT: decimalFormat = (DecimalFormat)NumberFormat.getPercentInstance(locale); break; } String pattern = (String)localizedPatterns.get(locale); if (pattern != null) { decimalFormat.applyPattern(pattern); } else if (nonLocalizedPattern != null) { decimalFormat.applyPattern(nonLocalizedPattern); } return decimalFormat; }
@Test public void testIsParseIntegerOnly () { if (verifyNoPropertyViolation()) { DecimalFormat dFormat = new DecimalFormat(); assertFalse(dFormat.isParseIntegerOnly()); dFormat.setParseIntegerOnly(true); assertTrue(dFormat.isParseIntegerOnly()); dFormat.setParseIntegerOnly(false); assertFalse(dFormat.isParseIntegerOnly()); NumberFormat format = NumberFormat.getIntegerInstance(); assertTrue(format.isParseIntegerOnly()); format = NumberFormat.getNumberInstance(); assertFalse(format.isParseIntegerOnly()); format = NumberFormat.getNumberInstance(Locale.ENGLISH); assertFalse(format.isParseIntegerOnly()); } }