Java Utililty Methods SQL Date Parse

List of utility methods to do SQL Date Parse

Description

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

Method

java.sql.DategetSQLDate(String dateString)
get SQL Date
Date date = new Date();
try {
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
    date = sdf.parse(dateString);
} catch (Exception e) {
    e.printStackTrace();
return new java.sql.Date(date.getTime());
...
java.sql.DategetSqlDate(String dateString, String format)
get Sql Date
SimpleDateFormat sdf = new SimpleDateFormat(format);
ParsePosition pos = new ParsePosition(0);
java.util.Date d = sdf.parse(dateString, pos);
return new java.sql.Date(d.getTime());
java.sql.DategetSqlDate(String str)
get Sql Date
try {
    if (str == null || str.equals("")) {
        return null;
    DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
    java.util.Date tempDate = df.parse(str);
    return new java.sql.Date(tempDate.getTime());
} catch (ParseException ex) {
...
java.sql.DategetSqlDateByShortStr(String dateStr)
get Sql Date By Short Str
java.sql.Date da = null;
try {
    da = new java.sql.Date(YYYYMMDD_FORMAT.parse(dateStr).getTime());
} catch (Exception e) {
    e.printStackTrace();
return da;
java.sql.DategetSqlDateFromStr(DateFormat format, String s, boolean need_default)
get Sql Date From Str
Date utilDate = getDateFromStr(format, s);
return utilDate_to_sqlDate(utilDate, need_default);
java.sql.DategetSQLDateFromStr(String s)
Convert Date String into sql Date
java.sql.Date dte = null;
try {
    String str = s;
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    java.util.Date dt = formatter.parse(str);
    dte = new java.sql.Date(dt.getTime());
} catch (Exception e) {
    e.printStackTrace();
...
java.sql.DategetSqlDateFromString(String dateAsString, String format)
converts a String to java.sql.Date
if (DISPLAY_DATE_FORMAT.equalsIgnoreCase(format)) {
    StringTokenizer dateAsTokens = new StringTokenizer(dateAsString, DISPLAY_DATE_DELIMITER);
    String month = dateAsTokens.nextToken();
    String date = dateAsTokens.nextToken();
    String year = dateAsTokens.nextToken();
    dateAsString = year + JDBC_DATE_DELIMITER + month + JDBC_DATE_DELIMITER + date;
    return java.sql.Date.valueOf(dateAsString);
else if (JDBC_DATE_ESCAPE_FORMAT.equalsIgnoreCase(format)) {
    return java.sql.Date.valueOf(dateAsString);
else {
    return null;
java.sql.Dateparse(String date)
Parse the string of data into java.sql.Date object
return parse(date, PATTERN_yyyy_MM_dd);
DateparseDate(final String dateString)
parse Date
if (dateString == null || "".equals(dateString.trim())) {
    return null;
return Date.valueOf(dateString);
DateparseDate(String date)
parse Date
try {
    if (date != null) {
        String[] items = date.split("/");
        Calendar calendar = Calendar.getInstance();
        calendar.set(Integer.parseInt(items[2]), Integer.parseInt(items[0]) - 1,
                Integer.parseInt(items[1]));
        return new Date(calendar.getTimeInMillis());
    } else {
...