class Hms extends Date { public Hms(double localOffset){ //假如HTML文件中設(shè)置了時區(qū),則把時間設(shè)為當(dāng)?shù)貢r區(qū)時間 super(); long tzOffset=getTimezoneOffset()*60L*1000L; localOffset *= 3600000.0; setTime(getTime() + tzOffset + (long)localOffset); }
public Hms(){ //假如沒有設(shè)置時區(qū),則就使用當(dāng)?shù)氐臅r間 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);