class ByteUtil {

    public static void writeLongAsAscii(final byte[] outputBuffer, final int offset, final long valueParam)
    {
        long value = valueParam;
        if (value < 0 || value > 9000000000000000000L)
        {
            throw new IllegalArgumentException("Value out of range: value=" + value);
        }

        int outputBufferIndex = offset + 18;

        long factor = 1;
        while (value >= factor)
        {
            long remainder = value % (factor * 10);

            outputBuffer[outputBufferIndex--] = (byte) ((remainder / factor) + 48);

            value -= remainder;
            factor *= 10;
        }

        final byte zero = (byte) 48;
        while (outputBufferIndex >= offset)
        {
            outputBuffer[outputBufferIndex--] = zero;
        }
    }

}