1 7 8 package java.sql; 9 10 22 public class Date extends java.util.Date { 23 24 36 @Deprecated 37 public Date(int year, int month, int day) { 38 super(year, month, day); 39 } 40 41 53 public Date(long date) { 54 super(date); 56 57 } 58 59 72 public void setTime(long date) { 73 super.setTime(date); 75 } 76 77 88 public static Date valueOf(String s) { 89 int year; 90 int month; 91 int day; 92 int firstDash; 93 int secondDash; 94 95 if (s == null) throw new java.lang.IllegalArgumentException (); 96 97 firstDash = s.indexOf('-'); 98 secondDash = s.indexOf('-', firstDash+1); 99 if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) { 100 year = Integer.parseInt(s.substring(0, firstDash)) - 1900; 101 month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1; 102 day = Integer.parseInt(s.substring(secondDash+1)); 103 } else { 104 throw new java.lang.IllegalArgumentException (); 105 } 106 107 return new Date (year, month, day); 108 } 109 110 126 public String toString () { 127 int year = super.getYear() + 1900; 128 int month = super.getMonth() + 1; 129 int day = super.getDate(); 130 131 char buf[] = "2000-00-00".toCharArray(); 132 buf[0] = Character.forDigit(year/1000,10); 133 buf[1] = Character.forDigit((year/100)%10,10); 134 buf[2] = Character.forDigit((year/10)%10,10); 135 buf[3] = Character.forDigit(year%10,10); 136 buf[5] = Character.forDigit(month/10,10); 137 buf[6] = Character.forDigit(month%10,10); 138 buf[8] = Character.forDigit(day/10,10); 139 buf[9] = Character.forDigit(day%10,10); 140 141 return new String (buf); 142 } 143 144 146 154 @Deprecated 155 public int getHours() { 156 throw new java.lang.IllegalArgumentException (); 157 } 158 159 167 @Deprecated 168 public int getMinutes() { 169 throw new java.lang.IllegalArgumentException (); 170 } 171 172 180 @Deprecated 181 public int getSeconds() { 182 throw new java.lang.IllegalArgumentException (); 183 } 184 185 193 @Deprecated 194 public void setHours(int i) { 195 throw new java.lang.IllegalArgumentException (); 196 } 197 198 206 @Deprecated 207 public void setMinutes(int i) { 208 throw new java.lang.IllegalArgumentException (); 209 } 210 211 219 @Deprecated 220 public void setSeconds(int i) { 221 throw new java.lang.IllegalArgumentException (); 222 } 223 224 228 static final long serialVersionUID = 1511598038487230103L; 229 } 230 231 | Popular Tags |