我正在尝试将System.currentTimeMillis转换为当前时间格式(hh:mm:ss)。到目前为止,这是我尝试过的,但它没有正常工作。
Long currentTime = System.currentTimeMillis();
int hours;
int minutes;
int seconds;
String getSecToStr = currentTime.toString();
String getTimeStr = getSecToStr.substring(8,13);
seconds = Integer.parseInt(getTimeStr);
minutes = seconds / 60;
seconds -= minutes * 60;
hours = minutes / 60;
minutes -= hours * 60;
String myResult = Integer.toString(hours) + ":" + Integer.toString(minutes) + ":" + Integer.toString(seconds);
System.out.println("Current Time Is: " + myResult);
有什么想法吗?非常感谢!