Java SQL Date From getCurrDateTime()

Here you can find the source of getCurrDateTime()

Description

get Curr Date Time

License

Apache License

Declaration

public static String getCurrDateTime() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String getCurrDateTime() {
        java.sql.Timestamp date = new java.sql.Timestamp(System.currentTimeMillis());
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return formatter.format(date);
    }/* ww w. jav a  2  s  .c  o  m*/

    /**
     * Returns a string the represents the passed-in date parsed
     * according to the passed-in format.  Returns an empty string
     * if the date or the format is null.
    **/
    public static String format(Date aDate, SimpleDateFormat aFormat) {
        if (aDate == null || aFormat == null) {
            return "";
        }
        synchronized (aFormat) {
            return aFormat.format(aDate);
        }
    }
}

Related

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