return hexString.toString();
}
+ /**
+ * Converts the given value to a hexadecimal string and zero-pads it to the
+ * given number of digits.
+ *
+ * @param value
+ * The value to convert
+ * @param digits
+ * The number of digits
+ * @return The formatted hexadecimal value
+ */
+ public static String toHex(long value, int digits) {
+ StringBuilder hexString = new StringBuilder();
+ hexString.append(Long.toHexString(value));
+ while (hexString.length() < digits) {
+ hexString.insert(0, '0');
+ }
+ return hexString.toString();
+ }
+
}