Java 8 DecimalFormatSymbols - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DecimalFormatSymbols class.

This code example shows how to use the following methods:setDecimalSeparator, setGroupingSeparator
  } 
  private static DecimalFormatSymbols decimalCommaSymbol = null;
 
  public static DecimalFormatSymbols decimalDotSymbol() {
    if(decimalDotSymbol == null) {
      decimalDotSymbol = new DecimalFormatSymbols();
      decimalDotSymbol.setDecimalSeparator(MONEY_SEPERATOR_DOT);      
      decimalDotSymbol.setGroupingSeparator(MONEY_SEPERATOR_COMMA);     
    } 
    return decimalDotSymbol;
  } 
  private static DecimalFormatSymbols decimalDotSymbol = null;
 
  public static DecimalFormatSymbols decimalFormatSymbols(char c) {   
    return (ERXDecimalFormatSymbols.MONEY_SEPERATOR_COMMA == c) ? ERXDecimalFormatSymbols.decimalCommaSymbol() : ERXDecimalFormatSymbols.decimalDotSymbol();
  } 
 
  public static DecimalFormatSymbols decimalFormatSymbols(String s) {   
    return ERXStringUtilities.stringIsNullOrEmpty(s) ? ERXDecimalFormatSymbols.decimalDotSymbol() : ERXDecimalFormatSymbols.decimalFormatSymbols(s.charAt(0));
  } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDecimalSeparator, setGroupingSeparator
            ret = new BigDecimal(0);
        } 
        return ret;
    } 
    public static String formatBalance(BigDecimal balance, String curr, boolean round) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        dfs.setDecimalSeparator(',');
        dfs.setGroupingSeparator(' ');
        DecimalFormat currency;
        if (!round) {
            currency = new DecimalFormat("#,##0.00 ");
        } 
        else { 
            currency = new DecimalFormat("#,##0 ");  
        } 
        currency.setDecimalFormatSymbols(dfs);
        return currency.format(balance.doubleValue())+curr;
    } 
    public static String formatBalance(BigDecimal balance, String curr) {
        return formatBalance(balance, curr, false);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setGroupingSeparator
	public void testProcess() throws Exception { 
		FromJsclSimplifyTextProcessor tp = new FromJsclSimplifyTextProcessor();
		//Assert.assertEquals("(e)", tp.process("(2.718281828459045)")); 
		//Assert.assertEquals("ee", tp.process("2.718281828459045*2.718281828459045")); 
		//Assert.assertEquals("((e)(e))", tp.process("((2.718281828459045)*(2.718281828459045))")); 
		DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols();
		decimalGroupSymbols.setGroupingSeparator(' ');
		Locator.getInstance().getEngine().setDecimalGroupSymbols(decimalGroupSymbols);
		//Assert.assertEquals("123 456 789e", tp.process("123456789*2.718281828459045")); 
		//Assert.assertEquals("123 456 789e", tp.process("123 456 789 * 2.718281828459045")); 
		//Assert.assertEquals("t11e", tp.process("t11*2.718281828459045")); 
		//Assert.assertEquals("e", tp.process("2.718281828459045")); 
		//Assert.assertEquals("tee", tp.process("t2.718281828459045*2.718281828459045")); 
 
		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t2.718281828459045", "2")); 
		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String) null));
		//Assert.assertEquals("t2.718281828459045e", tp.process("t2.718281828459045*2.718281828459045")); 
		//Assert.assertEquals("ee", tp.process("2.718281828459045*2.718281828459045")); 
		Assert.assertEquals("t×", tp.process("t*"));
		Assert.assertEquals("×t", tp.process("*t"));
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDecimalSeparator, setGroupingSeparator
	@Test 
	public void testRounding() throws Exception { 
		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0();
 
		try { 
			DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols(Locale.getDefault());
			decimalGroupSymbols.setDecimalSeparator('.');
			decimalGroupSymbols.setGroupingSeparator('\'');
			cm.setDecimalGroupSymbols(decimalGroupSymbols);
			cm.setPrecision(2);
			CalculatorTestUtils.assertEval("12'345'678.9", cm.evaluate("1.23456789E7"));
			cm.setPrecision(10);
			CalculatorTestUtils.assertEval("12'345'678.9", cm.evaluate("1.23456789E7"));
			CalculatorTestUtils.assertEval("123'456'789", cm.evaluate("1.234567890E8"));
			CalculatorTestUtils.assertEval("1'234'567'890.1", cm.evaluate("1.2345678901E9"));
		} finally { 
			cm.setPrecision(3);
			DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols(Locale.getDefault());
			decimalGroupSymbols.setDecimalSeparator('.');
			decimalGroupSymbols.setGroupingSeparator(JsclMathEngine.GROUPING_SEPARATOR_DEFAULT.charAt(0));
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
            return format.format(value);
        } 
 
        public static class Pattern extends Number { 
 
            private static final DecimalFormatSymbols SYMBOLS = new DecimalFormatSymbols(Locale.ROOT);
 
            static final byte ID = 4;
 
            String pattern;
 
            Pattern() {} // for serialization 
 
            public Pattern(String pattern) {
                super(new DecimalFormat(pattern, SYMBOLS));
                this.pattern = pattern;
            } 
 
            @Override 
            public byte id() { 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDecimalSeparator, getMinusSign
 
  /** 
   * The default constructor needed to fetch the locale dependant values. 
   */ 
  public FilterAcceptFloat() { 
    final DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault());
    minusChar = symbols.getMinusSign();
    decimalSeparator = symbols.getDecimalSeparator();
  } 
 
  @Override 
  public boolean acceptInput(final int index, final char newChar) {
    if (Character.isDigit(newChar)) {
      return true; 
    } 
 
    if ((newChar == minusChar) && (index == 0)) {
      return true; 
    } 
 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDecimalSeparator
     * @param source 
     * @return 
     * @throws ParseException 
     */ 
    public BigDecimal parse(String source) throws ParseException {
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setDecimalSeparator('.');
        DecimalFormat format = new DecimalFormat("#.#", symbols);
        format.setParseBigDecimal(true);
        return (BigDecimal) format.parse(source);
    } 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDecimalSeparator, getGroupingSeparator, getMinusSign
 
        DecimalFormatSymbols symbols = getSymbols(locale);
 
        JSONObject result = new JSONObject();
 
        result.put("groupingSeparator", toString(symbols.getGroupingSeparator()));
        result.put("minusSign", toString(symbols.getMinusSign()));
        result.put("decimalSeparator", toString(symbols.getDecimalSeparator()));
 
        return result;
    } 
 
    private DecimalFormatSymbols getSymbols(Locale locale)
    { 
        DecimalFormatSymbols symbols = symbolsCache.get(locale);
 
        if (symbols == null)
        { 
            symbols = new DecimalFormatSymbols(locale);
            symbolsCache.put(locale, symbols);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDecimalSeparator, setGroupingSeparator
  } 
  private static DecimalFormatSymbols decimalCommaSymbol = null;
 
  public static DecimalFormatSymbols decimalDotSymbol() {
    if(decimalDotSymbol == null) {
      decimalDotSymbol = new DecimalFormatSymbols();
      decimalDotSymbol.setDecimalSeparator(MONEY_SEPERATOR_DOT);      
      decimalDotSymbol.setGroupingSeparator(MONEY_SEPERATOR_COMMA);     
    } 
    return decimalDotSymbol;
  } 
  private static DecimalFormatSymbols decimalDotSymbol = null;
 
  public static DecimalFormatSymbols decimalFormatSymbols(char c) {   
    return (ERXDecimalFormatSymbols.MONEY_SEPERATOR_COMMA == c) ? ERXDecimalFormatSymbols.decimalCommaSymbol() : ERXDecimalFormatSymbols.decimalDotSymbol();
  } 
 
  public static DecimalFormatSymbols decimalFormatSymbols(String s) {   
    return ERXStringUtilities.stringIsNullOrEmpty(s) ? ERXDecimalFormatSymbols.decimalDotSymbol() : ERXDecimalFormatSymbols.decimalFormatSymbols(s.charAt(0));
  } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDecimalSeparator, setGroupingSeparator, setMinusSign
         
        if(format == null || number == null) {
            return null; 
        } 
 
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
         
        if (params.size() > 2) { 
            Character neg = getExpression(2).evaluate(feature, Character.class);
            symbols.setMinusSign(neg);
        } 
         
        if (params.size() > 3) { 
            Character dec = getExpression(3).evaluate(feature, Character.class);
            symbols.setDecimalSeparator(dec);
        } 
         
        if (params.size() > 4) { 
            Character grp = getExpression(4).evaluate(feature, Character.class);
            symbols.setGroupingSeparator(grp);

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 DecimalFormatSymbols Questions & Answers:

See Code Examples for Java 8 DecimalFormatSymbols Methods: