public class text {
public static void main(String args[]) {
tune t = new tune();
System.out.println(t.TOM());
t.setTime(13,14,00);
System.out.println(t.TOM());
}
}
tune类
public class tune {
private int hour;
private int minute;
private int secound;
public void setTime(int h,int m,int s){
hour=((h>=0 && h<24))?h:0;
minute=((m>=0 && m<60))?m:0;
secound=((s>=0 && s<60))?s:0;
}
public String TOM(){
return String.format("%02d:%02d:%02d", hour,minute,secound);
}
}
效果: