Java Utililty Methods SQL Date Create

List of utility methods to do SQL Date Create

Description

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

Method

DateconvertToDate(Object o)
Converts Object to Date.
if (o == null)
    return null;
if (o instanceof Date) {
    return (Date) o;
if (o instanceof Timestamp) {
    return new Date(new java.sql.Date(((Timestamp) o).getTime()).getTime());
if (o instanceof java.sql.Date) {
    return new Date(((java.sql.Date) o).getTime());
return dateformat.parse(o.toString());
java.sql.DateconvertToMySqlDate(Date date)
convert To My Sql Date
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strDate = dateFormat.format(date);
System.out.println(strDate);
java.sql.Date sqlDate;
try {
    sqlDate = new java.sql.Date(dateFormat.parse(strDate).getTime());
    System.out.println(strDate);
    return sqlDate;
...
java.sql.DateconvertToSDate(java.util.Date uDate)

convertToSDate

Chuyen ngay kieu java.util.Date thanh java.sql.Date
if (uDate == null) {
    return null;
} else {
    java.sql.Date sDate = new java.sql.Date(uDate.getTime());
    return sDate;
java.sql.DateconvertToSqlDate(Calendar calendar)
convert To Sql Date
return new java.sql.Date(calendar.getTimeInMillis());
DateconvertToSqlDate(java.util.Date argUtilDate)
convert To Sql Date
java.sql.Date sqlDate = null;
if (isNull(argUtilDate)) {
    return null;
} else {
    sqlDate = new java.sql.Date(argUtilDate.getTime());
return sqlDate;
java.sql.DateconvertToSQLDate(java.util.Date date)
convert To SQL Date
if (date != null) {
    String formated = DATEFORMAT.format(date);
    return java.sql.Date.valueOf(formated);
return null;
java.sql.DateConvertToSqlDate(java.util.Date date)
Convert To Sql Date
Long times = date.getTime();
java.sql.Date date1 = new java.sql.Date(times);
return date1;
java.sql.DateconvertToSqlDate(java.util.Date utilDate)
convert To Sql Date
return new java.sql.Date(utilDate.getTime());
java.sql.DateconvertToSqlDate(String str)
convert To Sql Date
SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
java.sql.Date sqlDate = null;
try {
    java.util.Date date = bartDateFormat.parse(str);
    sqlDate = new java.sql.Date(date.getTime());
} catch (Exception ex) {
    System.out.println(ex.getMessage());
return sqlDate;
java.util.DateconvertToUDate(String dateInString)

convertToUDate

Chuyen String dinh dang "dd/MM/yyyy" thanh ngay kieu java.util.Date
if (dateInString == null) {
    return null;
} else {
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    java.util.Date uDate = null;
    try {
        uDate = dateFormat.parse(dateInString);
    } catch (ParseException e) {
...