Java Decimal Round round(final double value)

Here you can find the source of round(final double value)

Description

round

License

Open Source License

Declaration

public static String round(final double value) 

Method Source Code


//package com.java2s;
// ProjectForge is dual-licensed.

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

public class Main {
    /**/*  w ww  .  j  a v  a  2  s .  c o  m*/
     * yyyy-MM-dd HH:mm:ss.S in UTC. Thread safe usage: FOR_TESTCASE_OUTPUT_FORMATTER.get().format(date)
     */
    private static final ThreadLocal<DecimalFormat> FORMAT_PRECISION_2 = new ThreadLocal<DecimalFormat>() {
        @Override
        protected DecimalFormat initialValue() {
            final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
            symbols.setDecimalSeparator('.');
            return new DecimalFormat("###.##", symbols);
        }
    };

    public static String round(final double value) {
        return FORMAT_PRECISION_2.get().format(value);
    }
}

Related

  1. round(double d, int n)
  2. round(double d, int p)
  3. round(double dValue)
  4. round(double number)
  5. round(double unrounded, int precision)
  6. roundAlloc(Double alloc)
  7. roundAndTruncate(double rawValue, int precision)
  8. roundDecimal(double d, int radix)
  9. roundDecimalPlaces(final double input, final int decimalPlaces)