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

DateconvertDateFromSQLDate(java.sql.Date sqlDate)
convert Date From SQL Date
if (null == sqlDate) {
    return null;
return new Date(sqlDate.getTime());
java.util.DateconvertDateFromSqlToUtil(java.sql.Date sqlDate)
convert Date From Sql To Util
java.util.Date utilDate = null;
if (sqlDate != null) {
    utilDate = new java.util.Date();
    long longTime = sqlDate.getTime();
    utilDate.setTime(longTime);
return utilDate;
DateconvertDateFromString(String inputDateString)
convert Date From String
DateFormat sf = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
return new Date(sf.parse(inputDateString).getTime());
java.sql.DateconvertDateFromUtilToSql(java.util.Date utilDate)
convert Date From Util To Sql
java.sql.Date sqlDate = null;
if (utilDate != null) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(utilDate);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
...
DateconvertDateIfNecessary(Date date)
convert Date If Necessary
if (getPlaceholderDate().equals(date)) {
    return null;
return date;
StringconvertDateToString(java.sql.Date argDate)
This method is used to convert date to the specified String format
String strDate = "";
if (argDate != null) {
    SimpleDateFormat dtFormat = new SimpleDateFormat("MM/dd/yyyy");
    strDate = dtFormat.format(argDate);
return strDate;
StringconvertFormat(java.sql.Date dt, String formatter)
conver date format
return convertFormat((java.util.Date) dt, formatter);
StringconvertFormat(String dateData)
convert Format
return convertFormat(dateData, "yyyy/MM/dd");
java.sql.DateconvertiFecha(Date utilFecha)
convierte un atributo tipo java.util.Date a un atributo tipo java.sql.Date
long fecha = utilFecha.getTime();
java.sql.Date sqlFecha = new java.sql.Date(fecha);
return sqlFecha;
StringconvertirSQLDate2String(java.sql.Date sqlDate)
convertir SQL Date String
long ms = sqlDate.getTime();
java.util.Date utilDate = new java.util.Date(ms);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
return sdf.format(utilDate);