Java Date to Timestamp dateToTimestamp(Date date)

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

Description

Converts a java.util.Date to a java.sql.Timestamp.

License

Open Source License

Declaration

public static Timestamp dateToTimestamp(Date date) 

Method Source Code

//package com.java2s;
/*//  w  w w .  ja  v a  2 s  .c o m
 * ***** BEGIN LICENSE BLOCK *****
 * Zimbra Collaboration Suite Server
 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014, 2016 Synacor, Inc.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software Foundation,
 * version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <https://www.gnu.org/licenses/>.
 * ***** END LICENSE BLOCK *****
 */

import java.sql.Timestamp;

import java.util.Date;

public class Main {
    /**
     * Converts a <tt>java.util.Date</tt> to a <tt>java.sql.Timestamp</tt>.
     * If the date is <tt>null</tt>, returns <tt>null</tt>.
     */
    public static Timestamp dateToTimestamp(Date date) {
        return date == null ? null : new Timestamp(date.getTime());
    }
}

Related

  1. compareDate(String timeStamp1, String timeStamp2)
  2. dateToTimestamp(Date date)
  3. dateToTimestamp(Date date)
  4. dateToTimestamp(Date date)
  5. dateToTimestamp(Date date)
  6. DateToTimestamp(Date time)