Java Code Examples for java.text.DecimalFormat#getNumberInstance()
The following examples show how to use
java.text.DecimalFormat#getNumberInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericExportWorker.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public GenericExportWorker() { Locale dateAndDecimalLocale = Locale.getDefault(); // Create the default number format decimalFormat = DecimalFormat.getNumberInstance(dateAndDecimalLocale); decimalFormat.setGroupingUsed(false); // Create the default date format dateFormat = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT, dateAndDecimalLocale); ((SimpleDateFormat) dateFormat).applyPattern(((SimpleDateFormat) dateFormat).toPattern().replaceFirst("y+", "yyyy")); // Create the default date and time format dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, dateAndDecimalLocale); ((SimpleDateFormat) dateTimeFormat).applyPattern(((SimpleDateFormat) dateTimeFormat).toPattern().replaceFirst("y+", "yyyy").replaceFirst(", ", " ")); }
Example 2
Source File: GenericExportWorker.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public void setDateAndDecimalLocale(Locale dateAndDecimalLocale) { dateFormat = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT, dateAndDecimalLocale); dateTimeFormat = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.MEDIUM, dateAndDecimalLocale); ((SimpleDateFormat) dateTimeFormat).applyPattern(((SimpleDateFormat) dateTimeFormat).toPattern().replaceFirst("y+", "yyyy").replaceFirst(", ", " ")); dateFormatter = null; dateTimeFormatter = null; decimalFormat = DecimalFormat.getNumberInstance(dateAndDecimalLocale); decimalFormat.setGroupingUsed(false); }
Example 3
Source File: NumberParser.java From cucumber with MIT License | 5 votes |
NumberParser(Locale locale) { numberFormat = DecimalFormat.getNumberInstance(locale); if (numberFormat instanceof DecimalFormat) { DecimalFormat decimalFormat = (DecimalFormat) numberFormat; decimalFormat.setParseBigDecimal(true); } }
Example 4
Source File: NumberParser.java From cucumber with MIT License | 5 votes |
NumberParser(Locale locale) { numberFormat = DecimalFormat.getNumberInstance(locale); if (numberFormat instanceof DecimalFormat) { DecimalFormat decimalFormat = (DecimalFormat) numberFormat; decimalFormat.setParseBigDecimal(true); } }
Example 5
Source File: MathUtils.java From latexdraw with GNU General Public License v3.0 | 5 votes |
private MathUtils() { super(); format = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.ENGLISH); format.setMaximumFractionDigits(3); format.setRoundingMode(RoundingMode.HALF_EVEN); format.getDecimalFormatSymbols().setDecimalSeparator('.'); format.setDecimalSeparatorAlwaysShown(false); format.setGroupingSize(0); doubleRegex = "[-]?[0-9]*\\.?[0-9]+"; }
Example 6
Source File: statTableRenderer.java From KEEL with GNU General Public License v3.0 | 3 votes |
/** * Builder */ public statTableRenderer() { super(); formatter = (DecimalFormat)DecimalFormat.getNumberInstance(); formatter.setMinimumFractionDigits(1); formatter.setMaximumFractionDigits(10); formatter.setGroupingUsed(false); }