1 7 8 package java.sql; 9 10 19 public class Time extends java.util.Date { 20 21 38 @Deprecated 39 public Time(int hour, int minute, int second) { 40 super(70, 0, 1, hour, minute, second); 41 } 42 43 50 public Time(long time) { 51 super(time); 52 } 53 54 61 public void setTime(long time) { 62 super.setTime(time); 63 } 64 65 71 public static Time valueOf(String s) { 72 int hour; 73 int minute; 74 int second; 75 int firstColon; 76 int secondColon; 77 78 if (s == null) throw new java.lang.IllegalArgumentException (); 79 80 firstColon = s.indexOf(':'); 81 secondColon = s.indexOf(':', firstColon+1); 82 if ((firstColon > 0) & (secondColon > 0) & 83 (secondColon < s.length()-1)) { 84 hour = Integer.parseInt(s.substring(0, firstColon)); 85 minute = 86 Integer.parseInt(s.substring(firstColon+1, secondColon)); 87 second = Integer.parseInt(s.substring(secondColon+1)); 88 } else { 89 throw new java.lang.IllegalArgumentException (); 90 } 91 92 return new Time (hour, minute, second); 93 } 94 95 100 public String toString () { 101 int hour = super.getHours(); 102 int minute = super.getMinutes(); 103 int second = super.getSeconds(); 104 String hourString; 105 String minuteString; 106 String secondString; 107 108 if (hour < 10) { 109 hourString = "0" + hour; 110 } else { 111 hourString = Integer.toString(hour); 112 } 113 if (minute < 10) { 114 minuteString = "0" + minute; 115 } else { 116 minuteString = Integer.toString(minute); 117 } 118 if (second < 10) { 119 secondString = "0" + second; 120 } else { 121 secondString = Integer.toString(second); 122 } 123 return (hourString + ":" + minuteString + ":" + secondString); 124 } 125 126 128 137 @Deprecated 138 public int getYear() { 139 throw new java.lang.IllegalArgumentException (); 140 } 141 142 151 @Deprecated 152 public int getMonth() { 153 throw new java.lang.IllegalArgumentException (); 154 } 155 156 164 @Deprecated 165 public int getDay() { 166 throw new java.lang.IllegalArgumentException (); 167 } 168 169 178 @Deprecated 179 public int getDate() { 180 throw new java.lang.IllegalArgumentException (); 181 } 182 183 192 @Deprecated 193 public void setYear(int i) { 194 throw new java.lang.IllegalArgumentException (); 195 } 196 197 206 @Deprecated 207 public void setMonth(int i) { 208 throw new java.lang.IllegalArgumentException (); 209 } 210 211 220 @Deprecated 221 public void setDate(int i) { 222 throw new java.lang.IllegalArgumentException (); 223 } 224 225 229 static final long serialVersionUID = 8397324403548013681L; 230 } 231 232 233 234 | Popular Tags |