Java Utililty Methods SQL Date

List of utility methods to do SQL Date

Description

The list of methods to do SQL Date are organized into topic(s).

Method

longstringToMillis(String str)
string To Millis
if (isAllDigits(str)) {
    return Long.parseLong(str);
} else if (str.length() == 10) {
    return stringToDate(str, DEFAULT_DATE_PATTERN).getTime();
} else if (str.length() == 19) {
    return stringToDate(str, DEFAULT_DATETIME_PATTERN_WITHOUT_MILLISECONDS).getTime();
} else if (str.length() == 23) {
    return stringToDate(str, DEFAULT_DATETIME_PATTERN_WITH_MILLISECONDS).getTime();
...
StringtoAge(String birthDay)
to Age
if (birthDay == null || birthDay.length() != 8) {
    return null;
int birthYear = Integer.parseInt(birthDay.substring(0, 4));
int birthMonth = Integer.parseInt(birthDay.substring(4, 6));
int birthDayOfMonth = Integer.parseInt(birthDay.substring(6, 8));
return toAge(birthYear, birthMonth, birthDayOfMonth);
Datetoday()
Gets the current date.
return new Date(System.currentTimeMillis());
java.sql.Datetoday()
today
return new java.sql.Date(todayCalendar().getTimeInMillis());
java.sql.Datetoday()
return current date (based on system time) as an SQL Date
GregorianCalendar d = new GregorianCalendar();
return new java.sql.Date(d.getTime().getTime());
java.sql.DatetodaySQL()
a date set at midnight
return new java.sql.Date(today().getTime());