Java Number Format formatRowKey(final long number, final int digits, byte[] dest)

Here you can find the source of formatRowKey(final long number, final int digits, byte[] dest)

Description

format Row Key

License

Open Source License

Declaration

public static void formatRowKey(final long number, final int digits, byte[] dest) 

Method Source Code

//package com.java2s;
/*/*from   ww w  .  j  a v  a  2 s.  co m*/
 * Copyright (C) 2007-2015 Hypertable, Inc.
 *
 * This file is part of Hypertable.
 *
 * Hypertable is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or any later version.
 *
 * Hypertable is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

public class Main {
    public static String formatRowKey(final long number, final int digits) {
        StringBuilder str = new StringBuilder(digits + 1);
        long d = Math.abs(number);
        str.setLength(digits);
        for (int ii = digits - 1; ii >= 0; ii--) {
            str.setCharAt(ii, (char) ((d % 10) + '0'));
            d /= 10;
        }
        return str.toString();
    }

    public static void formatRowKey(final long number, final int digits, byte[] dest) {
        long d = Math.abs(number);
        for (int ii = digits - 1; ii >= 0; ii--) {
            dest[ii] = (byte) ((d % 10) + '0');
            d /= 10;
        }
    }
}

Related

  1. formatPhone(String phoneNumber, String formattingPattern, String countryCode)
  2. formatPhoneNo(String country, String area, String number, String inline)
  3. formatPhoneNumber(String number)
  4. formatPhoneNumber(String phoneNumber)
  5. formatPrintIntegerToString(long number, boolean printCommasP, boolean printSignP, int radix, int mincol, char padchar, char commachar, int commainterval)
  6. formatSafetyNumber(String digits)
  7. formatSheetNumber100(final int sheetNumber)
  8. formatSmallerNumber(String prefix, String suffix, long amnt, boolean useDecimals)
  9. formatTo2Digit(int number)