Here you can find the source of long2string(long lng, StringBuilder buff)
private static void long2string(long lng, StringBuilder buff)
//package com.java2s; /*-/* w w w .j a v a 2 s. c om*/ * ============LICENSE_START======================================================= * SDC * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ public class Main { private static final char[] CHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private static void long2string(long lng, StringBuilder buff) { for (int i = 0; i < 16; i++) { long nextByte = lng & 0xF000000000000000L; lng <<= 4; boolean isNegative = nextByte < 0; nextByte = rightShift(nextByte, 60); if (isNegative) { nextByte |= 0x08; } buff.append(CHARS[(int) nextByte]); } } private static long rightShift(long lng, int num) { return lng >>> num; } }