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

java.sql.DateconvertJavaDate2SqlDate(java.util.Date date)
convert Java Date Sql Date
return new java.sql.Date(date.getTime());
DateconverToDate(String yyyy, String mm, String dd)
conver To Date
Date date = java.sql.Date.valueOf(yyyy + "-" + mm + "-" + dd);
return date;
DateconvertSqlDate(java.util.Date date)
convert Sql Date
Date result = null;
result = new Date(date.getTime());
return result;
CalendarconvertSqlDate2Calendar(java.sql.Date date)

Convert Date to Calendar.

Calendar cal = null;
if (date != null) {
    cal = GregorianCalendar.getInstance();
    cal.setTime(date);
return cal;
DateconvertSqlDateToJavaDate(java.sql.Date sqlDate)
convert Sql Date To Java Date
Date javaDate = null;
if (sqlDate != null) {
    javaDate = new Date(sqlDate.getTime());
return javaDate;
java.util.DateconvertSQLDateToUtilDate(java.sql.Date date)
convert SQL Date To Util Date
java.util.Date convertedDate = null;
date.setYear(date.getYear() - 1900);
date.setMonth(date.getMonth() - 1);
convertedDate = new java.util.Date(date.getTime());
return convertedDate;
java.sql.DateconvertSqlUtil(java.util.Date d)
convertSqlUtil Realiza la conversion un java.util.Date a java.sql.Date
java.sql.Date res = new java.sql.Date(new java.util.Date().getTime());
if (d != null) {
    res = new java.sql.Date(d.getTime());
return res;
TimestampconvertStringToSql(final String dateStr)
convert String To Sql
return new Timestamp(format.parse(dateStr).getTime());
CalendarconvertToCalendar(Date date)
convert To Calendar
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(date.getTime());
return calendar;
java.sql.DateconvertToDatabaseDate(Date date)
convert To Database Date
if (date == null)
    return null;
return new java.sql.Date(date.getTime());