Best code examples for Java 8 NumberFormat class (java.text.NumberFormat)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 NumberFormat class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 NumberFormat examples from Open Source projects
This code example shows how to use the following methods: getDecimalFormatSymbols, setDecimalFormatSymbols, format
30:	DecimalFormat df = new DecimalFormat("0E0"); 
31:	assertEquals("1E4", df.format(12345.)); 
-
33:	DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); 
-
35:	df.setDecimalFormatSymbols(dfs); 
36:	assertEquals("1-useless-api-4", df.format(12345.)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: format
158:	return format.format(value); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setDecimalFormatSymbols, format
114:	currency = new DecimalFormat("#,##0.00 "); 
-
119:	currency.setDecimalFormatSymbols(dfs); 
120:	return currency.format(balance.doubleValue())+curr; 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: format, setGroupingUsed, setMaximumFractionDigits, setMinimumFractionDigits, setMinimumIntegerDigits
6:	NumberFormat numForm = new DecimalFormat(); 
7:	numForm.setMinimumIntegerDigits(9); 
-
9:	numForm.setGroupingUsed(false);//stops it from inserting commas 
10:	System.out.println(numForm.format(7.125)); 
-
13:	numForm.setMinimumIntegerDigits(5); 
14:	numForm.setMinimumFractionDigits(5); 
15:	System.out.println(numForm.format(7.125)); 
16:	numForm.setMinimumFractionDigits(0); 
17:	numForm.setMaximumFractionDigits(2); 
18:	System.out.println(numForm.format(7.125)); 
19:	System.out.println(numForm.format(7.135));//rounds to even 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: parseObject, format, getMaximumFractionDigits, parse, isParseIntegerOnly
57:	assertEquals("\u0666-", format.format(-6)); 
58:	assertEquals(new Long(-36), format.parse("36-")); 
59:	assertEquals(new Long(-36), format.parseObject("36-")); 
60:	assertEquals(0, format.getMaximumFractionDigits()); 
61:	assertTrue(format.isParseIntegerOnly()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setGroupingUsed, setMinimumIntegerDigits
34:	idFormat.setMinimumIntegerDigits(4); 
35:	idFormat.setGroupingUsed(false); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: format, getMaximumFractionDigits, getMinimumFractionDigits, setMaximumFractionDigits, setMinimumFractionDigits
90:	int iOrigMaxFracDigits = format.getMaximumFractionDigits(); 
91:	int iOrigMinFracDigits = format.getMinimumFractionDigits(); 
92:	format.setMaximumFractionDigits(3); 
93:	format.setMinimumFractionDigits(format.getMinimumFractionDigits()); 
-
97:	format.format(bytes / ONE_MB, toAppendTo, pos); 
-
103:	format.format(bytes / ONE_KB, toAppendTo, pos); 
-
109:	int maxFrac = format.getMaximumFractionDigits(); 
110:	format.setMaximumFractionDigits(0); 
111:	format.format(bytes, toAppendTo, pos); 
112:	format.setMaximumFractionDigits(maxFrac); 
-
118:	format.setMaximumFractionDigits(iOrigMaxFracDigits); 
119:	format.setMinimumFractionDigits(iOrigMinFracDigits); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: applyPattern, format, parse
111:	format.applyPattern("*x##,##,#,##0.0#"); 
112:	assertEquals("xxxxxxxxx123.0", format.format(123)); 
113:	assertEquals(123, format.parse("xxxxxxxxx123.0").intValue()); 
-
115:	format.applyPattern("$*x#,##0.00"); 
116:	assertEquals("$xx123.00", format.format(123)); 
117:	assertEquals("$1,234.00", format.format(1234)); 
-
119:	format.applyPattern("*\u00e7#0 o''clock"); 
120:	assertEquals("\u00e72 o'clock", format.format(2)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setGroupingUsed, setMinimumIntegerDigits
53:	NUMBER_FORMAT.setMinimumIntegerDigits(5); 
54:	NUMBER_FORMAT.setGroupingUsed(false); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDecimalFormatSymbols, setMinimumFractionDigits, format
31:	DecimalFormat decimalFormat = new DecimalFormat("0.00##################E0"); 
32:	decimalFormat.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); 
33:	decimalFormat.setMinimumFractionDigits(fractionDigits.intValue()); 
34:	return Types.rewritePossiblyExponentialValue(decimalFormat.format(number.doubleValue())); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: format
101:	DecimalFormat df = new DecimalFormat("0000000000"); 
102:	String rowKey = df.format(1); 
-
105:	rowKey = df.format(2); 
-
108:	rowKey = df.format(5); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setGroupingUsed, setMinimumIntegerDigits
33:	idFormat.setMinimumIntegerDigits(4); 
34:	idFormat.setGroupingUsed(false); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDecimalSeparatorAlwaysShown, setMaximumFractionDigits, setMinimumFractionDigits, format
112:	DecimalFormat percentFormat = new DecimalFormat("0.00%"); 
-
115:	percentFormat.setDecimalSeparatorAlwaysShown(false); 
116:	percentFormat.setMinimumFractionDigits(digits); 
117:	percentFormat.setMaximumFractionDigits(digits); 
118:	return percentFormat.format(rounded / scale); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDecimalFormatSymbols, setParseBigDecimal, parse
191:	decimalFormat = new DecimalFormat(effectiveFormatString); 
192:	decimalFormat.setParseBigDecimal(true); 
193:	decimalFormat.setDecimalFormatSymbols(new DecimalFormatSymbols(localeUsed)); 
-
196:	return decimalFormat.parse(String.valueOf(o)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: format
58:	DecimalFormat df = new DecimalFormat("0.00");// 以Mb为单位保留两位小数 
59:	String filesize = df.format(size); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: format
61:	DecimalFormat f = new DecimalFormat("00.0"); 
62:	assertEquals("51°46'"+f.format(43.0)+"\"", LatLon.dms(latlon.lat())); 
63:	assertEquals("8°21'"+f.format(56.3)+"\"", LatLon.dms(latlon.lon())); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getDecimalFormatSymbols, setDecimalFormatSymbols, format
30:	DecimalFormat df = new DecimalFormat("0E0"); 
31:	assertEquals("1E4", df.format(12345.)); 
-
33:	DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); 
-
35:	df.setDecimalFormatSymbols(dfs); 
36:	assertEquals("1-useless-api-4", df.format(12345.)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: format, setGroupingUsed, setMaximumFractionDigits
127:	this.numberFormatter.setGroupingUsed(false); 
128:	this.numberFormatter.setMaximumFractionDigits(digits); 
-
130:	return this.numberFormatter.format(d); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setGroupingUsed, setMinimumIntegerDigits
35:	idFormat.setMinimumIntegerDigits(4); 
36:	idFormat.setGroupingUsed(false); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: format
156:	final DecimalFormat numberFormat = new DecimalFormat("#.##"); 
-
159:	averageValueStr = numberFormat.format(averageValue); 
-
163:	averageCountStr = numberFormat.format(averageCount); 
-
165:	return String.format(OUTPUT_FORMAT, numberFormat.format(count), numberFormat.format(values), averageValueStr, 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: parseObject, format, getMaximumFractionDigits, parse, isParseIntegerOnly
57:	assertEquals("\u0666-", format.format(-6)); 
58:	assertEquals(new Long(-36), format.parse("36-")); 
59:	assertEquals(new Long(-36), format.parseObject("36-")); 
60:	assertEquals(0, format.getMaximumFractionDigits()); 
61:	assertTrue(format.isParseIntegerOnly()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setMaximumFractionDigits
62:	percFormatter.setMaximumFractionDigits(3); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDecimalFormatSymbols, setDecimalSeparatorAlwaysShown, setMaximumFractionDigits, format
67:	result.append(format.format(value)); 
-
71:	result.append(format.format(value)); 
-
75:	result.append(format.format(value)); 
-
155:	format = new DecimalFormat("0.0"); 
156:	format.setMaximumFractionDigits(3); 
157:	format.setDecimalSeparatorAlwaysShown(true); 
-
160:	format.setDecimalFormatSymbols(symbols); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: toPattern, parseObject, format, getMaximumFractionDigits, parse
177:	"#,##0;#,##0-", format.toPattern()); 
-
180:	"\u0666-", format.format(-6)); 
-
183:	new Long(-36), format.parse("36-")); 
-
186:	new Long(-36), format.parseObject("36-")); 
-
190:	0, format.getMaximumFractionDigits()); 
-
193:	format.isParseIntegerOnly()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDecimalSeparatorAlwaysShown, setMaximumFractionDigits, setMinimumFractionDigits, format
113:	DecimalFormat percentFormat = new DecimalFormat("0.00%"); 
-
116:	percentFormat.setDecimalSeparatorAlwaysShown(false); 
117:	percentFormat.setMinimumFractionDigits(digits); 
118:	percentFormat.setMaximumFractionDigits(digits); 
119:	return percentFormat.format(rounded / scale); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: format
326:	NumberFormat nf = new DecimalFormat("0.#"); 
-
331:	s = nf.format(f / (1024 * 1024)) + " GB"; 
-
335:	s = nf.format(f / (1024)) + " MB"; 
-
339:	s = nf.format(f) + " bytes"; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: format
76:	+ " late: " + logFormat.format(lateCount) 
77:	+ " lost: " + logFormat.format(lostCount) 
78:	+ " jit: "  + logFormat.format(jitCount) 
79:	+ " veryLate: " + logFormat.format(veryLateCount) 
80:	+ " avgDelay: " + logFormat.format(avgDelay) 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setGroupingUsed, setMinimumIntegerDigits
53:	NUMBER_FORMAT.setMinimumIntegerDigits(5); 
54:	NUMBER_FORMAT.setGroupingUsed(false); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setGroupingUsed, setMinimumIntegerDigits
40:	idFormat.setMinimumIntegerDigits(4); 
41:	idFormat.setGroupingUsed(false); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: clone, setGroupingUsed, setParseIntegerOnly
56:	return (NumberFormat)numberFormat.clone(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getDecimalFormatSymbols, setDecimalFormatSymbols, format
30:	DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); 
-
33:	df.setDecimalFormatSymbols(dfs); 
-
36:	return df.format(Double.parseDouble(number.toString())); 
-
55:	return format(new DecimalFormat("0.00"), number); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setGroupingUsed, setMaximumFractionDigits, setMinimumFractionDigits
34:	COORD_FORMATTER.setMinimumFractionDigits(1); 
35:	COORD_FORMATTER.setGroupingUsed(false); 
36:	COORD_FORMATTER.setMaximumFractionDigits(16); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: parse
191:	format.parse(value); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: format
73:	return idFormat.format(rand.nextLong()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: applyPattern, setMaximumFractionDigits, setMinimumIntegerDigits, format
55:	format.setMinimumIntegerDigits(1); 
56:	format.setMaximumFractionDigits(2); 
57:	format.applyPattern("##0.##"); 
-
59:	String formattedNumber = format.format(number * 100); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setMaximumFractionDigits
49:	format.setMaximumFractionDigits(3); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDecimalFormatSymbols, format
55:	DecimalFormat format = new DecimalFormat("0.00"); 
-
58:	format.setDecimalFormatSymbols(instance); 
59:	return format.format(value); 
Full Snippet Info
6
CodeRank
Related Java 8 NumberFormat Questions & Answers:
See Code Examples for Java 8 NumberFormat Methods: