我需要在java中将分钟转换为小时和分钟,所以我这样做 的 的java:
long minutes = offer.getDuration();
long hours = minutes / 60;
long minnutesRemaining = minutes % 60;
trainOffer.setDuration(hours+"h"+minnutesRemaining);
输出:
minutes = 129
hours = 2
minnutesRemaining = 9
我该如何处理minnutesRemaining = 09
?
答案 0 :(得分:2)
使用String.format格式化输出:
System.out.println(String.format("%02d", minnutesRemaining ));