Java SQL Date Create convert(Date date)

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

Description

Given a java.util.Date, return a java.sql.Date.

License

Open Source License

Parameter

Parameter Description
date the java.util.Date to convert

Return

the date in java.sql.Date

Declaration

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

Method Source Code

//package com.java2s;
/*//from   w  w w . j av a  2  s .  c o m
 * Copyright 2011-2013 StackFrame, LLC
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3
 * as published by the Free Software Foundation.
 *
 * You should have received a copy of the GNU General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Date;

public class Main {
    /**
     * Given a java.util.Date, return a java.sql.Date.
     *
     * @param date the java.util.Date to convert
     * @return the date in java.sql.Date
     */
    public static java.sql.Date convert(Date date) {
        if (date instanceof java.sql.Date) {
            return (java.sql.Date) date;
        } else {
            return new java.sql.Date(date.getTime());
        }
    }
}

Related

  1. asSqlDate(Date date)
  2. asSqlDate(String date)
  3. beforeNow(final Date d)
  4. beginOfDay(Date date)
  5. castToSqlDate(Object value)
  6. convertDate(java.sql.Date date)
  7. convertDateFromSQLDate(java.sql.Date sqlDate)
  8. convertDateFromSqlToUtil(java.sql.Date sqlDate)
  9. convertDateFromString(String inputDateString)