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.util.DateparseDate(String dateStr, String formatStr)
parse Date
SimpleDateFormat format = new SimpleDateFormat(formatStr);
try {
    return format.parse(dateStr);
} catch (ParseException e) {
    e.printStackTrace();
    return null;
DateparseDate(String exifDate)
parse Date
if (exifDate == null) {
    return null;
String patterns[];
int i;
patterns = (new String[] { "yyyy:MM:dd HH:mm:ss", "yyyy:MM:dd HH:mm", "yyyy-MM-dd HH:mm:ss",
        "yyyy-MM-dd HH:mm", "dd.MM.yy HH:mm", "yyyyMMdd HHmmss", "yyyyMMdd.HHmmss", "yyyyMMdd HHmm",
        "MM/dd/yy hh:mm a", "HH:mm:ss dd.MM.yyyy", "yyyy:MM:dd", "yyyy-MM-dd", "dd.MM.yy", "yyyyMMdd",
...
DateparseDate(String s)
parse Date
Calendar c = Calendar.getInstance();
try {
    int d = Integer.parseInt(s);
    int year = d / 10000;
    int month = (d % 10000) / 100;
    int day = d % 100;
    c.set(year, month - 1, day);
} catch (Exception e) {
...
java.sql.DateparseDate(String s)
parse Date
return java.sql.Date.valueOf(s);
DateparseDate(String strDate)
parse Date
long r = 0;
try {
    StringTokenizer token = new StringTokenizer(strDate, " ");
    String date = token.nextToken();
    Date now = java.sql.Date.valueOf(date);
    r = now.getTime();
    try {
        String time = token.nextToken();
...
DateparseDate(String strFormat, String dateValue)
Parse a string and return the date value in the specified format
if (dateValue == null)
    return null;
if (strFormat == null)
    strFormat = TIME_PATTERN_DEFAULT;
SimpleDateFormat dateFormat = new SimpleDateFormat(strFormat);
Date newDate = null;
try {
    newDate = dateFormat.parse(dateValue);
...
CalendarparseDate(String value, String format)
Parse the date of the format.
Calendar date = Calendar.getInstance();
date.setTime(new SimpleDateFormat(format).parse(value));
return date;
StringparseDate2(Date date, String pattern)
parse Date
DateFormat df = new SimpleDateFormat(pattern);
return df.format(date);
StringparseDateE(Date dt)
Parse a java.sql.Date to String
return new SimpleDateFormat(DATE_FORMAT_E).format(dt);
java.sql.DateparseDateString(String tmp, String format)
Takes a string and tries to convert it to a Date based on the specified formatting
java.sql.Date dateValue = null;
SimpleDateFormat df = null;
df = new SimpleDateFormat(format);
try {
    java.util.Date tmpDate = df.parse(tmp, new ParsePosition(0));
    dateValue = new java.sql.Date(new java.util.Date().getTime());
    dateValue.setTime(tmpDate.getTime());
    return dateValue;
...