Java Timestamp Now getCurrentTimeStamp()

Here you can find the source of getCurrentTimeStamp()

Description

Produce an instance of Timestamp which can produce a string representation understood by Derby, and which reflects the current Date and Time.

License

Open Source License

Return

- instance of java.sql.Timestamp

Declaration

public static Timestamp getCurrentTimeStamp() 

Method Source Code

//package com.java2s;
/*//from w  ww.j ava  2 s .  c om
    
 Copyright IBM Corp. 2012, 2016
 This file is part of Anomaly Detection Engine for Linux Logs (ADE).

 ADE 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, either version 3 of the License, or
 (at your option) any later version.

 ADE 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 ADE.  If not, see <http://www.gnu.org/licenses/>.
    
 */

import java.sql.Timestamp;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    /** 
     * Produce an instance of Timestamp which can produce a string 
     * representation understood by Derby, and which reflects the 
     * current Date and Time.
     * 
     * @return - instance of java.sql.Timestamp
     */
    public static Timestamp getCurrentTimeStamp() {

        final Calendar cal = new GregorianCalendar();
        final Date currDate = cal.getTime();
        return new Timestamp(currDate.getTime());

    }
}

Related

  1. getCurrentDateAsTimestamp()
  2. getCurrentDateTimestamp()
  3. getCurrentDBTimestamp()
  4. getCurrentSQLTimestamp()
  5. getCurrentSQLTimestamp()
  6. getCurrentTimeStamp()
  7. getCurrentTimeStamp()
  8. getCurrentTimestamp()
  9. getCurrentTimestamp()