Formats the frequency range as bizarrely reported by the EQ API into something readable. - Java java.lang

Java examples for java.lang:Math Algorithm

Description

Formats the frequency range as bizarrely reported by the EQ API into something readable.

Demo Code


//package com.java2s;

public class Main {
    /** Formats the frequency range as bizarrely reported by the EQ
     *    API into something readable. */
    public static String formatBandLabel(int[] band) {
        return milliHzToString(band[0]) + "-" + milliHzToString(band[1]);
    }//from   w  w  w.  java2s .  com

    private static String milliHzToString(int milliHz) {
        if (milliHz < 1000)
            return "";
        if (milliHz < 1000000)
            return "" + (milliHz / 1000) + "Hz";
        else
            return "" + (milliHz / 1000000) + "kHz";
    }
}

Related Tutorials