Java Long Number to Time getSpeedString(long castTime, long bytes)

Here you can find the source of getSpeedString(long castTime, long bytes)

Description

get Speed String

License

Open Source License

Declaration

public static String getSpeedString(long castTime, long bytes) 

Method Source Code


//package com.java2s;
import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    private static final NumberFormat SIZE_FORMAT_M = new DecimalFormat("###.##M/s");
    private static final NumberFormat SIZE_FORMAT_K = new DecimalFormat("####K/s");

    public static String getSpeedString(long castTime, long bytes) {
        double castSecond = (double) castTime / (double) 1000;
        return parseSpeedString((long) ((double) bytes / castSecond) / 1024);
    }//w ww.j a  v a 2 s .c  om

    private static String parseSpeedString(long size) {
        if (size > 1024) {
            return SIZE_FORMAT_M.format(((float) size) / 1024);
        }
        return SIZE_FORMAT_K.format(size);
    }
}

Related

  1. getReadableDate(long longTime)
  2. getServerTime(long offset)
  3. getShortTimeText(Long oldTime)
  4. getSimpleDate(long time)
  5. getSMillon(long time)
  6. getStrDateForLong(long time)
  7. getTextDate(long timeInMs)
  8. getTime(long nanos)
  9. getTime(Long time)