Java SQL Date Create createDateFormater(int dataType)

Here you can find the source of createDateFormater(int dataType)

Description

create DateFormate depend on dataType.

License

Open Source License

Parameter

Parameter Description
dataType a parameter

Declaration

public static DateFormat createDateFormater(int dataType) 

Method Source Code


//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

import java.sql.Types;
import java.text.DateFormat;

import java.text.SimpleDateFormat;

public class Main {
    /**//from  w  ww.ja  v a2 s. c om
     * 
     * create DateFormate depend on dataType.
     * 
     * @param dataType
     * @return
     */
    public static DateFormat createDateFormater(int dataType) {
        SimpleDateFormat ret;
        switch (dataType) {
        case Types.TIME:
            ret = new SimpleDateFormat("HH:mm:ss");//$NON-NLS-1$
            break;
        case Types.TIMESTAMP:
            ret = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//$NON-NLS-1$
            break;
        case Types.DATE:
        default:
            ret = new SimpleDateFormat("yyyy-MM-dd");//$NON-NLS-1$
            break;
        }
        return ret;
    }
}

Related

  1. getLastDayOfMonth(java.sql.Date date)
  2. getLastDayOfPreviousMonth(Date date, boolean isFormatDate)
  3. getLastSundayDate()
  4. getLongDate(String strDate)
  5. createDate(int day, int month, int year)
  6. createFutureDate(java.sql.Date lmpDate, int offSet)
  7. createRecGetStatementsUpdate(String tip, String imeFirstCap)
  8. createSqlDate(String dateStr)
  9. createStreamingStatement(Connection conn, boolean update)