private static String idToCode(final String praefix, final long id) {
        String code = "";
        final long idToUse = id < 0 ? 0 : id;
        final boolean isLowNumber = idToUse <= 65535;

        final long base = isLowNumber ? GC_BASE16 : GC_BASE31;
        int rest = 0;
        long divResult = isLowNumber ? idToUse : idToUse + 411120;

        while (divResult != 0) {
            rest = (int) (divResult % base);
            divResult = divResult / base;
            code = SEQUENCE_GCID.charAt(rest) + code;
        }

        return StringUtils.isBlank(code) ? "" : praefix + code;
    }
Converts logId to LogCode. For invalid id's, empty string will be returned (never null)
main/src/main/java/cgeo/geocaching/connector/gc/GCUtils.java