public ConstantData() { super(); nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); }
public void setDefault() { int i, nrfields = 0; allocate( nrfields ); DecimalFormat decimalFormat = new DecimalFormat(); for ( i = 0; i < nrfields; i++ ) { fieldName[i] = "field" + i; fieldType[i] = "Number"; fieldFormat[i] = "\u00A40,000,000.00;\u00A4-0,000,000.00"; fieldLength[i] = 9; fieldPrecision[i] = 2; currency[i] = decimalFormat.getDecimalFormatSymbols().getCurrencySymbol(); decimal[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getDecimalSeparator() } ); group[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getGroupingSeparator() } ); value[i] = "-"; setEmptyString[i] = false; } }
DecimalFormatSymbols DcmFrmSmb = new DecimalFormatSymbols( Locale.getDefault()); DcmFrmSmb.setDecimalSeparator('.'); DcmFrmSmb.setGroupingSeparator(' '); DcmFrm = new DecimalFormat( DFS, DcmFrmSmb ); Result = DcmFrm.format( Value );
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(currentLocale); otherSymbols.setDecimalSeparator(','); otherSymbols.setGroupingSeparator('.'); DecimalFormat df = new DecimalFormat(formatString, otherSymbols);
//create a new instance DecimalFormatSymbols custom=new DecimalFormatSymbols(); custom.setDecimalSeparator(','); format.setDecimalFormatSymbols(custom);
/** * Copies the DecimalFormatSymbols settings into our native peer in bulk. */ public void setDecimalFormatSymbols(final DecimalFormatSymbols dfs) { setDecimalFormatSymbols(this.address, dfs.getCurrencySymbol(), dfs.getDecimalSeparator(), dfs.getDigit(), dfs.getExponentSeparator(), dfs.getGroupingSeparator(), dfs.getInfinity(), dfs.getInternationalCurrencySymbol(), dfs.getMinusSign(), dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(), dfs.getPercent(), dfs.getPerMill(), dfs.getZeroDigit()); }
public void guessType() { NumberFormat nf = NumberFormat.getInstance(); DecimalFormat df = (DecimalFormat) nf; DecimalFormatSymbols dfs = new DecimalFormatSymbols(); SimpleDateFormat daf = new SimpleDateFormat(); decimal = "" + dfs.getDecimalSeparator(); grouping = "" + dfs.getGroupingSeparator(); dfs.setDecimalSeparator( '.' ); decimal = "."; dfs.setGroupingSeparator( ',' ); grouping = ","; } else if ( !contains_dot && contains_comma ) { dfs.setDecimalSeparator( ',' ); decimal = ","; dfs.setGroupingSeparator( '.' ); grouping = "."; } else if ( contains_dot && contains_comma ) { int idx_com = field.indexOf( ',' ); if ( idx_dot > idx_com ) { dfs.setDecimalSeparator( '.' ); decimal = "."; dfs.setGroupingSeparator( ',' ); grouping = ","; } else { dfs.setDecimalSeparator( ',' ); decimal = ",";
long fileLineNumber = 0; DecimalFormatSymbols dfs = new DecimalFormatSymbols(); field.setLength( -1 ); field.setPrecision( -1 ); field.setCurrencySymbol( dfs.getCurrencySymbol() ); field.setDecimalSymbol( "" + dfs.getDecimalSeparator() ); field.setGroupSymbol( "" + dfs.getGroupingSeparator() ); field.setNullString( "-" ); field.setTrimType( ValueMetaInterface.TRIM_TYPE_NONE ); DecimalFormat df2 = (DecimalFormat) NumberFormat.getInstance(); DecimalFormatSymbols dfs2 = new DecimalFormatSymbols(); SimpleDateFormat daf2 = new SimpleDateFormat(); df2.applyPattern( mask ); df2.setDecimalFormatSymbols( dfs2 ); double mn = df2.parse( seResult.getMin().toString() ).doubleValue(); message.append( BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Info.NumberExample", mask, seResult.getMin(), Double.toString( mn ) ) ); maxdate.toString() ) );
String LocaleCountry = new Locale("en").getDefault().getCountry(); String LocaleLanguage = new Locale("en").getDefault().getLanguage(); String LocaleCurrency = new DecimalFormatSymbols().getCurrency().toString(); String LocaleShortDateTimePattern =new SimpleDateFormat().toPattern(); char LocaleDecimalSeparator = new DecimalFormatSymbols().getDecimalSeparator(); char LocaleThousandSeparator = new DecimalFormatSymbols().getGroupingSeparator(); String LocaleThousandGrouping = String.format("%d;0", new DecimalFormat().getMaximumFractionDigits()); String LocaleNegativePrefix = new DecimalFormat().getNegativePrefix(); String LocaleNegativeSuffix =new DecimalFormat().getNegativeSuffix(); String Operator = Utils.getQwnername(context);
new String[] { "full", "long", "medium", "short" }); if (dateStyle == -1) { Format.upToWithQuotes(string, position, buffer, '}', '{'); return new SimpleDateFormat(buffer.toString(), locale); case 2: // number if (ch == '}') { return NumberFormat.getInstance(locale); Format.upToWithQuotes(string, position, buffer, '}', '{'); return new DecimalFormat(buffer.toString(), new DecimalFormatSymbols(locale)); return NumberFormat.getCurrencyInstance(locale); case 1: // percent return NumberFormat.getPercentInstance(locale); return NumberFormat.getIntegerInstance(locale); Format.upToWithQuotes(string, position, buffer, '}', '{'); } catch (IllegalArgumentException e) {
formats[i] = new DecimalFormat(((DecimalFormat) format) .toPattern(), new DecimalFormatSymbols(locale)); } catch (NullPointerException npe){ formats[i] = null; formats[i] = new SimpleDateFormat(((SimpleDateFormat) format) .toPattern(), locale); } catch (NullPointerException npe) { formats[i] = null;
if (!(localeObj instanceof Locale)) return; Locale newLocale = (Locale)localeObj; if (!localeIsAdapting || newLocale.equals(locale)) return; decimalSymbols = DecimalFormatSymbols.getInstance(locale); generalNumberFormat = new ExcelGeneralNumberFormat(locale); defaultDateformat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", dateSymbols); defaultDateformat.setTimeZone(LocaleUtil.getUserTimeZone());
data.df.applyPattern( field.getFormat() ); } else { data.df.applyPattern( data.defaultDecimalFormat.toPattern() ); data.dfs.setDecimalSeparator( field.getDecimalSymbol().charAt( 0 ) ); } else { data.dfs.setDecimalSeparator( data.defaultDecimalFormatSymbols.getDecimalSeparator() ); data.dfs.setGroupingSeparator( field.getGroupingSymbol().charAt( 0 ) ); } else { data.dfs.setGroupingSeparator( data.defaultDecimalFormatSymbols.getGroupingSeparator() ); data.dfs.setCurrencySymbol( field.getCurrencySymbol() ); } else { data.dfs.setCurrencySymbol( data.defaultDecimalFormatSymbols.getCurrencySymbol() ); if ( field != null && !Utils.isEmpty( field.getFormat() ) && valueMeta.getDate( valueData ) != null ) { if ( !Utils.isEmpty( field.getFormat() ) ) { data.daf.applyPattern( field.getFormat() ); } else { data.daf.applyPattern( data.defaultDateFormat.toLocalizedPattern() ); data.daf.setDateFormatSymbols( data.dafs );
static String formatPercent(double value) { DecimalFormat percentFormatter = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); return percentFormatter.format(value) + "%"; }
public String formatNumber(double value) { DecimalFormat formatter = new DecimalFormat("###,###.00"); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault()); symbols.setDecimalSeparator(','); symbols.setGroupingSeparator('.'); formatter.setDecimalFormatSymbols(symbols); return formatter.format(value); }
DecimalFormat myFormatter = new DecimalFormat(pattern); String output = myFormatter.format(value); System.out.println(value + " " + pattern + " " + output); NumberFormat nf = NumberFormat.getNumberInstance(loc); DecimalFormat df = (DecimalFormat)nf; df.applyPattern(pattern); String output = df.format(value); System.out.println(pattern + " " + output + " " + loc.toString()); customFormat("\u00a5###,###.###", 12345.67); Locale currentLocale = new Locale("en", "US"); new DecimalFormatSymbols(currentLocale); unusualSymbols.setDecimalSeparator('|'); unusualSymbols.setGroupingSeparator('^'); String strange = "#,##0.###"; DecimalFormat weirdFormatter = new DecimalFormat(strange, unusualSymbols); weirdFormatter.setGroupingSize(4); String bizarre = weirdFormatter.format(12345.678); new Locale("en", "US"), new Locale("de", "DE"), new Locale("fr", "FR")
private String formatTime(float time) { DecimalFormatSymbols symbols = new DecimalFormatSymbols(); // JUnitReports wants points here, regardless of the locale symbols.setDecimalSeparator('.'); DecimalFormat format = new DecimalFormat("#.###", symbols); format.setMinimumFractionDigits(3); return format.format(time / 1000.0f); }
DecimalFormat df = new DecimalFormat("#,##0.###", new DecimalFormatSymbols(new Locale("pt", "BR"))); String mb = df.format(fileSizeInMB); lengh = mb + " MB";
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault()); symbols.setGroupingSeparator(' ');//simple space DecimalFormat df = new DecimalFormat("#,###.00", symbols); BigDecimal example = new BigDecimal("1250"); String str = df.format(example);
public static FormatLocale createLocale(Locale locale) new DecimalFormatSymbols(locale); final DateFormatSymbols dateSymbols = new DateFormatSymbols(locale); NumberFormat.getCurrencyInstance(locale); final String currencyValue = currencyFormat.format(123456.78); String currencyLeft = currencyValue.substring(0, currencyValue.indexOf("1")); StringBuilder buf = new StringBuilder(); buf.append(currencyLeft); int minimumIntegerDigits = currencyFormat.getMinimumIntegerDigits(); for (int i = Math.max(minimumIntegerDigits, 4) - 1; i >= 0; --i) { buf.append(i < minimumIntegerDigits ? '0' : '#'); String currencySymbol = decimalSymbols.getCurrencySymbol(); if (currencySymbol.equals(Format.intlCurrencySymbol + "")) { final DecimalFormatSymbols defaultDecimalSymbols = new DecimalFormatSymbols(Locale.getDefault()); currencySymbol = defaultDecimalSymbols.getCurrencySymbol(); decimalSymbols.getGroupingSeparator(), decimalSymbols.getDecimalSeparator(), dateSeparator, timeSeparator,