Java SQL Date From getCurAllTime()

Here you can find the source of getCurAllTime()

Description

RETURN DATE STRING FORMAT "yyyy-MM-dd HH:mm:ss"

License

Open Source License

Declaration

public static String getCurAllTime() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /************************************************************
     * RETURN DATE STRING FORMAT "yyyy-MM-dd HH:mm:ss"
     ************************************************************/
    public static String getCurAllTime() {
        Timestamp ts = null;//  w w w. jav a  2  s  .  c  om

        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String d = sdf.format(new java.util.Date());
            ts = Timestamp.valueOf(d);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        return ts.toString().substring(0, 19);
    }
}

Related

  1. convertTimeToHour(long time)
  2. convertToDateTime(java.util.Date date, String time)
  3. convertToTime(Date toDate)
  4. convertToTime(java.util.Date date)
  5. getCNTimezone()
  6. getCurrDateTime()
  7. getCurrentDateTime()
  8. getCurrentTime()
  9. getCurrentTime()