Java Today getTodayTimeForDB()

Here you can find the source of getTodayTimeForDB()

Description

get Today Time For DB

License

Open Source License

Declaration

public static String getTodayTimeForDB() throws Exception 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String getTodayTimeForDB() throws Exception {
        return getDate(new Date(), "yyyy/MM/dd HH:mm:ss");
    }/*from   w  ww. ja v  a  2s  . c  om*/

    public static String getDate(Date pDate, String pFormat) {

        if (pDate == null)
            return "";

        StringBuffer ret = new StringBuffer();
        new SimpleDateFormat(pFormat).format(pDate, ret, new FieldPosition(0));
        return ret.toString();
    }

    public static Date getDate(String strDate, String pFormat) throws Exception {
        if (strDate == null)
            return null;

        return new SimpleDateFormat(pFormat).parse(strDate, new ParsePosition(0));
    }
}

Related

  1. getTodayString()
  2. getTodayString()
  3. getTodayString()
  4. getTodayString()
  5. getTodayTime()
  6. getTodayWithTime(final String iTime)
  7. getTodayYmd()
  8. getTodayYMD()
  9. getTodayZero()