【发布时间】:2018-04-17 15:08:39
【问题描述】:
我尝试过这样做:
long Plptime = player.getStatistic(Statistic.PLAY_ONE_TICK)*50L; //from ticks to ms(1 tick (20 each sec) by 50 gives aprox the ms)
SimpleDateFormat formatter = new SimpleDateFormat("dd 'days,' HH
'hours and' mm 'minutes'", Locale.getDefault());
Date date = new Date(Plptime);
String result1 = formatter.format(date);
但是当它向玩家发送字符串消息时(顺便说一下,我的世界),小时和天从 1 开始,而分钟从 0 开始,例如,当有人刚加入他的游戏时,将是 01days 01 hours 00 min。有什么解决办法吗?谢谢
【问题讨论】:
-
How to convert Milliseconds to “X mins, x seconds” in Java? 可能重复这个问题和类似问题已经被问过并回答了很多次,所以我建议你使用搜索引擎找到你喜欢的答案。
-
我建议你避免使用
SimpleDateFormat类。它不仅过时了,而且出了名的麻烦。今天我们在java.time, the modern Java date and time API 的表现要好得多。
标签: date time minecraft bukkit milliseconds