Java Money Format toMemoryString(double bytes)

Here you can find the source of toMemoryString(double bytes)

Description

to Memory String

License

LGPL

Declaration

public static String toMemoryString(double bytes) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static String toMemoryString(double bytes) {
        double display = bytes;
        if (display < 1024)
            return display + "b";
        display /= 1024.0;/*from   w  w w . ja va2s. c o  m*/
        if (display < 1024)
            return String.format("%-1.1f", display) + "kb";
        display /= 1024.0;
        if (display < 1024)
            return String.format("%-1.1f", display) + "mb";
        display /= 1024.0;
        return String.format("%-1.1f", display) + "gb";

    }
}

Related

  1. getMoneyFormat(double money)
  2. getMoneyString(double money)
  3. hourAndMinutesToString(int hours, int minutes)
  4. moneyDelFormat(String s)
  5. str2money(String str)
  6. toMemoryUnits(double value)
  7. toMoney(long amount)