Java SQL Date Create getCurSQLDateInString(String pstrDateFormat)

Here you can find the source of getCurSQLDateInString(String pstrDateFormat)

Description

Get current date in form of java.sql.Date and then convert it into String.

License

Apache License

Return

String representation of current date.

Declaration

public static String getCurSQLDateInString(String pstrDateFormat) 

Method Source Code

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

import java.text.SimpleDateFormat;

public class Main {
    /**/*from   ww w .j a va2 s.  c  o m*/
     * Get current date in form of java.sql.Date and then convert it into
     * String. The return date string follow that of the input param DateFormat.
     * 
     * @return String representation of current date.
     */
    public static String getCurSQLDateInString(String pstrDateFormat) {
        String pstrDateTime = null;
        if ((pstrDateFormat != null) && (!pstrDateFormat.equals(""))) {
            java.util.Date curDateTime = new java.util.Date();
            java.sql.Date curSqlDateTime = new java.sql.Date(curDateTime.getTime());
            SimpleDateFormat sdf = new SimpleDateFormat(pstrDateFormat);
            pstrDateTime = sdf.format(curSqlDateTime);
        }
        return pstrDateTime;
    }
}

Related

  1. getCurrentDateWithMinutePrecision()
  2. getCurrentDayStartDate(Date date)
  3. getCurrentDBDate()
  4. getCurrentSQLDate()
  5. getCurSQLDate()
  6. getDataMaior(java.sql.Date data1, java.sql.Date data2)
  7. getDateAfter(Date date, Integer after)
  8. getDateAfter(Date date, long offset)
  9. getDateAsString(int month, int date, int year)