/** *Constructsa{@codeDate}objectinitializedwiththegiven *year,month,andday. *<P> *Theresultisundefinedifagivenargumentisoutofbounds. * *@paramyeartheyearminus1900;mustbe0to8099.(Notethat *8099is9999minus1900.) *@parammonth0to11 *@paramday1to31 *@deprecatedinsteadusetheconstructor{@codeDate(longdate)}
*/
@Deprecated(since="1.2") public Date(int year, int month, int day) { super(year, month, day);
}
/** *Constructsa{@codeDate}objectusingthegivenmilliseconds *timevalue.Ifthegivenmillisecondsvaluecontainstime *information,thedriverwillsetthetimecomponentstothe *timeinthedefaulttimezone(thetimezoneoftheJavavirtual *machinerunningtheapplication)thatcorrespondstozeroGMT. * *@paramdatemillisecondssinceJanuary1,1970,00:00:00GMTnot *toexceedthemillisecondsrepresentationfortheyear8099. *Anegativenumberindicatesthenumberofmilliseconds *beforeJanuary1,1970,00:00:00GMT.
*/ public Date(long date) { // If the millisecond date value contains time info, mask it out. super(date);
}
/** *Setsanexisting{@codeDate}object *usingthegivenmillisecondstimevalue. *Ifthegivenmillisecondsvaluecontainstimeinformation, *thedriverwillsetthetimecomponentstothe *timeinthedefaulttimezone(thetimezoneoftheJavavirtual *machinerunningtheapplication)thatcorrespondstozeroGMT. * *@paramdatemillisecondssinceJanuary1,1970,00:00:00GMTnot *toexceedthemillisecondsrepresentationfortheyear8099. *Anegativenumberindicatesthenumberofmilliseconds *beforeJanuary1,1970,00:00:00GMT.
*/ publicvoid setTime(long date) { // If the millisecond date value contains time info, mask it out. super.setTime(date);
}
/** *ConvertsastringinJDBCdateescapeformatto *a{@codeDate}value. * *@paramsa{@codeString}objectrepresentingadatein *intheformat"yyyy-[m]m-[d]d".Theleadingzerofor{@codemm} *and{@codedd}mayalsobeomitted. *@returna{@codejava.sql.Date}objectrepresentingthe *givendate *@throwsIllegalArgumentExceptionifthedategivenisnotinthe *JDBCdateescapeformat(yyyy-[m]m-[d]d)
*/ publicstatic Date valueOf(String s) { if (s == null) { thrownew java.lang.IllegalArgumentException();
} finalint YEAR_LENGTH = 4; finalint MONTH_LENGTH = 2; finalint DAY_LENGTH = 2; finalint MAX_MONTH = 12; finalint MAX_DAY = 31;
Date d = null;
int firstDash = s.indexOf('-'); int secondDash = s.indexOf('-', firstDash + 1); int len = s.length();
if ((firstDash > 0) && (secondDash > 0) && (secondDash < len - 1)) { if (firstDash == YEAR_LENGTH &&
(secondDash - firstDash > 1 && secondDash - firstDash <= MONTH_LENGTH + 1) &&
(len - secondDash > 1 && len - secondDash <= DAY_LENGTH + 1)) { int year = Integer.parseInt(s, 0, firstDash, 10); int month = Integer.parseInt(s, firstDash + 1, secondDash, 10); int day = Integer.parseInt(s, secondDash + 1, len, 10);
if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) {
d = new Date(year - 1900, month - 1, day);
}
}
} if (d == null) { thrownew java.lang.IllegalArgumentException();
}
return d;
}
/** *Formatsadateinthedateescapeformatyyyy-mm-dd. * *@returnaStringinyyyy-mm-ddformat
*/
@SuppressWarnings("deprecation") public String toString () { int year = super.getYear() + 1900; int month = super.getMonth() + 1; int day = super.getDate();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.