public static String toHexString(long number) { byte[] bytes = ByteUtil.longToBytes(number); return toHexString(bytes); }
@Test public void testToHexString() { assertEquals("", HexUtil.toHexString(null)); }
private static JsonObject getJsonObjectFromFile(String dir, String fileName) { String seedPath = String.format("classpath:/%s/%s", dir, fileName); Resource resource = new DefaultResourceLoader().getResource(seedPath); try (InputStream is = resource.getInputStream()) { Reader json = new InputStreamReader(is, StandardCharsets.UTF_8); JsonObject jsonObject = JsonUtil.parseJsonObject(json); if (!jsonObject.has("timestamp")) { long timestamp = TimeUtils.time(); jsonObject.addProperty("timestamp", HexUtil.toHexString(timestamp)); } return jsonObject; } catch (Exception e) { throw new NonExistObjectException(seedPath); } }