Android Float Format formatSpeedValue(float speed)

Here you can find the source of formatSpeedValue(float speed)

Description

format Speed Value

Declaration

public static String formatSpeedValue(float speed) 

Method Source Code

//package com.java2s;

public class Main {
    public static String formatSpeedValue(float speed) {
        java.text.DecimalFormat df = new java.text.DecimalFormat("#0.00");
        String str = "";
        if (speed >= 0 && speed < 1024.0) {
            df = new java.text.DecimalFormat("#0");
            str = df.format(speed) + "KB/s";
        } else if (speed >= 1024 && speed < (1024 * 1024.0)) {
            str = df.format(speed / 1024) + "MB/s";
        } else if (speed >= (1024 * 1024) && speed < (1024 * 1024 * 1024.0)) {
            str = df.format(speed / (1024 * 1024.0)) + "GB/s";
        } else if (speed >= (1024 * 1024 * 1024)
                && speed < (1024 * 1024 * 1024 * 1024)) {
            str = df.format(speed / (1024 * 1024 * 1024.0)) + "TB/s";
        }/*  w w w.j  a  v  a  2 s  . c  o m*/
        return str;
    }
}

Related

  1. formatFloatValue(float value)
  2. formatFloat(float money)
  3. formatAmount(float f)
  4. formatSpeed(float data)
  5. formatSpeed(float data, String format)
  6. formatSpeedWithUnit(float speed)
  7. formatSpeed(float bytesPerSecond)
  8. priceFormat(float price, String pattern)