我收到一条以秒为单位的文本(例如 7261)。我需要将它转换成这种格式:2h, 1m, 1s
我正在使用 time4j 库。根据他们的Github page,我正在做这样的事情:
val duration = Duration.of(7261, ClockUnit.SECONDS).with(Duration.STD_CLOCK_PERIOD)
val prettifiedDuration = PrettyTime.of(Locale.ENGLISH).print(duration)
但是,我收到此错误:
06-22 11:50:52.133 12161 12244 E AndroidRuntime: java.lang.ExceptionInInitializerError
06-22 11:50:52.133 12161 12244 E AndroidRuntime: at net.time4j.base.ResourceLoader.getInstance(ResourceLoader.java:167)
06-22 11:50:52.133 12161 12244 E AndroidRuntime: at net.time4j.PrettyTime.<clinit>(PrettyTime.java:95)
06-22 11:50:52.133 12161 12244 E AndroidRuntime: at net.time4j.PrettyTime.of(PrettyTime.java:198)
任何想法?甚至,更好的解决方案?