Java Timestamp Now getTimestamp()

Here you can find the source of getTimestamp()

Description

get Timestamp

License

Open Source License

Declaration

public static Timestamp getTimestamp() 

Method Source Code


//package com.java2s;

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {

    public static Timestamp getTimestamp() {
        return new Timestamp(getTime());
    }//from ww w .ja  v a  2  s  . c o  m

    public static long getTime() {
        java.util.Date dt = new java.util.Date();
        return dt.getTime();
    }

    public static String getTime(String s) {
        if (s == null || s.equals(""))
            return "";
        String s1 = "";
        try {
            SimpleDateFormat simpledateformat = new SimpleDateFormat(s);
            s1 = simpledateformat.format(Calendar.getInstance().getTime());
        } catch (Exception exception) {
            System.out.println(Calendar.getInstance().toString() + "cannot format time [function:getTime(String)]");
            exception.printStackTrace();
        }
        return s1;
    }
}

Related

  1. getCurrentTimeStamp(String format)
  2. getCurrentTimestampAsString()
  3. getNowTimeStamp()
  4. getTimestamp()
  5. getTimestamp()
  6. getTimestamp()
  7. getTimestamp()
  8. getTimeStamp()
  9. getTimeStamp()