Java Size Format formatDecimal(double size)

Here you can find the source of formatDecimal(double size)

Description

Format decimal numbers to #.##

License

Open Source License

Parameter

Parameter Description
size Size to format.

Return

Decimal formatted.

Declaration

public static String formatDecimal(double size) 

Method Source Code

//package com.java2s;

import java.math.RoundingMode;
import java.text.DecimalFormat;

public class Main {
    /**//www  . j a  v  a 2s  . co  m
     * Format decimal numbers to #.##
     * 
     * @param size
     *            Size to format.
     * @return Decimal formatted.
     */
    public static String formatDecimal(double size) {
        DecimalFormat df = new DecimalFormat("#.###");
        df.setRoundingMode(RoundingMode.CEILING);
        return df.format(size);
    }
}

Related

  1. formatBytes(double size)
  2. formatBytes(long size)
  3. formatByteSize(long bytes)
  4. formatDataSize(final double dataSize)
  5. formatDataSize(long bytes)
  6. formatDiskSize(final long diskSize)
  7. formatFileSize(double fileSize, int precision, int unit, boolean showUnit)
  8. formatFileSize(File file)
  9. formatFilesize(final long filesize, final Locale locale)