Java 使用 String.format 格式化 Hex 时间戳
可以使用 String.format 方法来简化代码,如下所示:
hexDateTime = String.format('%06x', Long.parseLong(dateTime));
这段代码使用 String.format 方法将 dateTime 转换为长整型,并以十六进制格式(%x)进行格式化,确保长度为 6 位(%06x)。
原文地址: https://www.cveoy.top/t/topic/n9sU 著作权归作者所有。请勿转载和采集!