@@ -0,0 +1,1732 @@
+/*%0A *%0A *  * Copyright 2014 http://Bither.net%0A *  *%0A *  * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  * you may not use this file except in compliance with the License.%0A *  * You may obtain a copy of the License at%0A *  *%0A *  *    http://www.apache.org/licenses/LICENSE-2.0%0A *  *%0A *  * Unless required by applicable law or agreed to in writing, software%0A *  * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  * See the License for the specific language governing permissions and%0A *  * limitations under the License.%0A *%0A */%0A%0Apackage net.bither.bitherj.utils;%0A%0A/**%0A * Created by songchenwen on 14-11-12.%0A */%0Apublic class UnitUtil %7B%0A    public static enum BitcoinUnit %7B%0A        BTC(100000000), bits(100);%0A%0A        public long satoshis;%0A%0A        BitcoinUnit(long satoshis) %7B%0A            this.satoshis = satoshis;%0A        %7D%0A    %7D%0A%0A    public static String formatValue(final long value, BitcoinUnit unit) %7B%0A        String sign = value %3C 0 ? %22-%22 : %22%22;%0A        long absValue = Math.abs(value);%0A        long coins = absValue / unit.satoshis;%0A        long satoshis = absValue %25 unit.satoshis;%0A        String strCoins = Long.toString(coins);%0A        String strSatoshis = %22%22;%0A        strSatoshis = Long.toString(satoshis + unit.satoshis);%0A        strSatoshis = strSatoshis.substring(1, strSatoshis.length());%0A        if (unit.satoshis %3E Math.pow(10, 2)) %7B%0A            strSatoshis = strSatoshis.replaceFirst(%22%5B0%5D%7B1,%22 + Integer.toString((int) Math.floor%0A                    (Math.log10(unit.satoshis) - 2)) + %22%7D$%22, %22%22);%0A        %7D%0A        return sign + strCoins + (strSatoshis.length() %3E 0 ? %22.%22 : %22%22) + strSatoshis;%0A    %7D%0A%7D%0A

add UnitUtil