java的问题

Tian3seawolf 2015-02-01 01:48:21
public class ShowCurrentTime
{
public static void main(String[] args)
{
//Obtain the total millseconds since midnight, Jan 1, 1970
long totalMilliseconds=System.currentTimeMillis();

//Obtain the total seconds since midnight, Jan 1, 1970
long totalSeconds=totalMilliseconds /1000;

//Compute the current second in the minute in the hour
long currentSecond=totalSeconds %60;

//Obtain the total minutes
long totalMinutes =totalSeconds /60;

//Compute the current minute in the hour
long currentMinute =totalMinutes %60;

//Obtain the total hours
long currentHour = totalHours % 24;

//Display results
System.out.println("Current time is"+currentHour+":"+currentMinute
+":"+currentSecond+"GMT");

}

}
也不知道是错在哪里?编译运行的时候提示
totalHours不能转换成变量 求高人指点
...全文
123 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tian3seawolf 2015-02-01
  • 打赏
  • 举报
回复
谢谢高人提醒,我才开始学JAVA,勿怪!!!!!!!!!!!
邹邹wl 2015-02-01
  • 打赏
  • 举报
回复
long currentHour = totalHours % 24;
这个前面应该加上
long totalHours =totalMinutes /60;
姜小白- 2015-02-01
  • 打赏
  • 举报
回复
你的代码中totalHours 根本就没有定义过,怎么使用呢?

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧