code: @Nonnull
    public static String getFormatted (final double dValue,
                                       @Nonnegative final int nScale,
                                       @Nonnull final EDecimalType eType,
                                       @Nonnull final Locale aLocale)
    {
      ValueEnforcer.isGE0 (nScale, "Scale");
      ValueEnforcer.notNull (eType, "Type");
      ValueEnforcer.notNull (aLocale, "Locale");
  
      if (Double.isNaN (dValue) || Double.isInfinite (dValue))
        return Double.toString (dValue);
  
      // Avoid negative scales
      final DecimalFormat aDF = (DecimalFormat) NumberFormat.getInstance (aLocale);
      aDF.setDecimalFormatSymbols (DecimalFormatSymbols.getInstance (aLocale));
      aDF.setMaximumFractionDigits (nScale);
      aDF.setMinimumFractionDigits (nScale);
  
      if (eType.isExponential ())
      {
        String sPattern = "0E0";
        if (nScale > 0)
          sPattern += '.' + StringHelper.getRepeated ('0', nScale);
        aDF.applyPattern (sPattern);
      }
      else
      {
        aDF.setGroupingUsed (false);
        aDF.setMinimumIntegerDigits (1);
      }
      return aDF.format (dValue);
    }
docs: Source: http://www.luschny.de/java/doubleformat.html
  
  @param dValue
  the value to be formatted
  @param nScale
  The precision of the decimal scale. If type is
  {@link EDecimalType#FIX} the decimal scale, else the (carrying scale
  - 1). Should be &ge; 0.
  @param eType
  The formatting type. May not be <code>null</code>.
  @param aLocale
  The locale to be used for the decimal symbols. May not be
  <code>null</code>.
  @return the string representation of the double value. For NaN and infinite
  values, the return of {@link Double#toString()} is returned.