请帮我看一下java取系统时间的代码

yao450860487 yao450860487 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

<html>
<body>
<applet code="Clock.class" width="300",height="300">
</applet>
</body>
</html>

/**
* @(#)Clock.java
*
*
* @author
* @version 1.00 2008/12/21
*/
import javax.swing.*;
import java.util.Date;

public class Clock extends java.applet.Applet {

/** Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
Mytime time=new Mytime(0,0,0);

JPanel panel=new JPanel();
String s=time.getMyTime();
JLabel label=new JLabel(s);
add(label);

}

}


class Mytime extends Date
{
public Mytime(int h,int m,int s)
{
hours=h;
minutes=m;
seconds=s;
}
public String getMyTime()
{
hours=getHours();
minutes=getMinutes();
seconds=getSeconds();

return hours+":"+minutes+":"+seconds;

}

protected int hours, minutes, seconds;

}

在其他人机子上就能取出正确时间,我机子上取的时间却了错,请问是不是电脑上有病毒,还是本身系统时间有问题(但在桌面显示的时间又是正确的)
...全文

相关推荐

评论 17
收藏 已收藏
分享
返回顶部
yao450860487
Java SE 62,620 成员 307,251 内容