import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;
public class test {
public static void main(String[] args) {
Time time1=new Time();
Time time2=new Time(555550000);
Time time3=new Time(3,80,3700);
System.out.println(time1.toString());
System.out.println(time2.toString());
System.out.println(time3.toString());
}
}
class Time{
private long hour,minute,second;
public Time(){
setTime(System.currentTimeMillis());
}
public Time(long elapsedTime){
setTime(elapsedTime);
}
public Time(long hour,long minute,long second){
this.second=second%60;
this.minute=(second/60+minute)%60;
this.hour=(second/60+minute/60+hour)%60;
}
public void setTime(long elapsedTime){
long totalSeconds = elapsedTime / 1000;
second = (long)(totalSeconds % 60);
long totalMinutes = totalSeconds / 60;
minute = (long)(totalMinutes % 60);
long totalHours = (int)(totalMinutes / 60);
hour = (long)(totalHours % 24);
}
public void setTime(int hour,int minute,int second){
this.hour=hour;
this.minute=minute;
this.second=second;
}
@Override
public String toString() {
return "Hour: " + this.hour + " Minute: " + this.minute + " Second: " + this.second;
}
}