Java SQL Date From toSqlDate(Date date)

Here you can find the source of toSqlDate(Date date)

Description

toSqlDate (date): convert Date to SQL Date

License

Open Source License

Parameter

Parameter Description
date Date

Return

SQL Date

Declaration

public static java.sql.Date toSqlDate(Date date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    /**/*  w ww. jav a2  s  .  co  m*/
     * <code>toSqlDate (date):</code> convert Date to SQL Date
     * @param date   Date
     * @return SQL Date
     */
    public static java.sql.Date toSqlDate(Date date) {
        if (date == null)
            return null;
        java.sql.Date sqlDate = new java.sql.Date(date.getTime());
        return sqlDate;
    }

    /**
     * <code>toSqlDate (cal):</code> convert Calendar to SQL Date
     * @param cal   Calendar
     * @return SQL Date
     */
    public static java.sql.Date toSqlDate(Calendar cal) {
        if (cal == null)
            return null;
        java.sql.Date sqlDate = new java.sql.Date(cal.getTime().getTime());
        return sqlDate;
    }

    /**
     * <code>getTime (timezone):</code> get the time now
     * @param zone   time zone
     * @return Calendar instance
     */
    public static Calendar getTime(TimeZone zone) {
        return Calendar.getInstance(zone);
    }
}

Related

  1. toDateMidnight(java.util.Date d)
  2. toDateStr(java.util.Date d)
  3. toSqlDate(Calendar calendar)
  4. toSqlDate(Date date)
  5. toSqlDate(Date date)
  6. toSqlDate(Date date)
  7. toSqlDate(Date dt)
  8. toSqlDate(final Date date)
  9. toSqlDate(final String _text, final String _dateFormat)