class Hms extends Date { public Hms(double localOffset){ //假如HTML文件中设置了时区,则把时间设为当地时区时间 super(); long tzOffset=getTimezoneOffset()*60L*1000L; localOffset *= 3600000.0; setTime(getTime() + tzOffset + (long)localOffset); }
public Hms(){ //假如没有设置时区,则就使用当地的时间 super(); }
public double get_hours() //时间换算,把如5:30这样的时间换算成5.5 { return (double)super.getHours()+(double)getMinutes()/60.0; } }
abstract class ClockHand //抽象类,提供时针、分针、秒针类使用 { PRotected int baseX[], baseY[]; protected int transX[],transY[]; protected int numberOfPoints;
public ClockHand(int originX, int originY, int length,int thickness,int points){ baseX= new int[points]; baseY=new int[points]; transX= new int[points]; transY=new int[points]; initiallizePoints(originX,originY,length,thickness); numberOfPoints=points; }
abstract protected void initiallizePoints( int originX, int originY, int length, int thickness);
abstract public void draw(Color color, double angle, Graphics g);
//秒针使用的类 class SweepHand extends ClockHand { public SweepHand(int originX,int originY, int length, int points) { super(originX,originY,length,0,points);