Java Timestamp Now getCurrentTimestamp()

Here you can find the source of getCurrentTimestamp()

Description

get Current Timestamp

License

Open Source License

Declaration

public static Timestamp getCurrentTimestamp() 

Method Source Code

//package com.java2s;
/**/*from   www. java  2s . com*/
 *  Copyright (c) 2011, Eryptogram.java TAIHEIOT and/or its affiliates. All rights reserved.
 *
 *  Licensed under the TAIHEIOT License, Version 1.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Timestamp getCurrentTimestamp() {
        return new Timestamp((new Date()).getTime());
    }

    public static String getTime(java.util.Date date) {
        return formatDateHMS(date);
    }

    public static String formatDateHMS(java.util.Date date) {
        String result = "";
        if (date != null) {
            try {
                SimpleDateFormat dateFormater = new SimpleDateFormat("HH:mm:ss");
                result = dateFormater.format(date);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        return result;
    }
}

Related

  1. getCurrentTimeStamp()
  2. getCurrentTimestamp()
  3. getCurrentTimestamp()
  4. getCurrentTimestamp()
  5. getCurrentTimeStamp()
  6. getCurrentTimeStamp()
  7. getCurrentTimestamp()
  8. getCurrentTimestamp()
  9. getCurrentTimeStamp(int offsetDays)