Java Utililty Methods SQL Date From

List of utility methods to do SQL Date From

Description

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

Method

DatetoDate(Object obj)
to Date
if (obj instanceof java.util.Date) {
    return (Date) obj;
if (obj instanceof java.sql.Date) {
    java.sql.Date sqlDate = (java.sql.Date) obj;
    return new Date(sqlDate.getTime());
if (obj instanceof Calendar) {
...
java.sql.DatetoDate(Object value)
Convert an Object to a Date.
if (value == null) {
    return null;
if (value instanceof java.sql.Date) {
    return (java.sql.Date) value;
if (value instanceof String) {
    if ("".equals((String) value)) {
...
DatetoDate(String dateString)
to Date
return parseDate(dateString);
DatetoDate(String s)
Convert String to Date
int len = s.length();
if (len >= 10) {
    int c4 = s.charAt(4);
    int c7 = s.charAt(7);
    if (c4 == '-' && c7 == '-') {
        return Date.valueOf(s.substring(0, 10));
return null;
DatetoDateFromString(String str)
to Date From String
DateFormat format = new SimpleDateFormat(DATE_FORMAT_DEFAULT);
Date date = null;
try {
    date = format.parse(str);
} catch (ParseException e) {
    e.printStackTrace();
return date;
...
DateMidnighttoDateMidnight(java.util.Date d)
to Date Midnight
DateMidnight dm = (d == null ? null : new DateMidnight(d));
return dm;
StringtoDateStr(java.util.Date d)
to Date Str
if (d == null) {
    return null;
} else {
    return (new SimpleDateFormat(Simple_Date_Format)).format(d);
java.sql.DatetoSqlDate(Calendar calendar)
to Sql Date
if (calendar == null) {
    return null;
return new java.sql.Date(calendar.getTimeInMillis());
java.sql.DatetoSqlDate(Date date)
null safe convert from util date to sql date
if (date == null) {
    return null;
return new java.sql.Date(date.getTime());
java.sql.DatetoSqlDate(Date date)
to Sql Date
if (date != null) {
    return new java.sql.Date(date.getTime());
} else {
    return null;