Java SQL Date Create convertToUDate(String dateInString)

Here you can find the source of convertToUDate(String dateInString)

Description

convertToUDate

Chuyen String dinh dang "dd/MM/yyyy" thanh ngay kieu java.util.Date

License

Apache License

Parameter

Parameter Description
dateInString String

Return

uDate - java.util.Date hoac null

Declaration

public static java.util.Date convertToUDate(String dateInString) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**/*  ww  w  .ja va  2 s.c o m*/
     * <h1>convertToUDate</h1> Chuyen ngay kieu java.util.Date thanh
     * java.sql.Date
     * 
     * @param sDate
     *            java.sql.Date
     * @return uDate - java.util.Date hoac null
     */
    public static java.util.Date convertToUDate(java.sql.Date sDate) {
        if (sDate == null) {
            return null;
        } else {
            java.util.Date uDate = new Date(sDate.getTime());
            return uDate;
        }

    }

    /**
     * <h1>convertToUDate</h1> Chuyen ngay kieu java.sql.Timestamp thanh
     * java.util.Date
     * 
     * @param timeStamp
     *            java.sql.Timestamp
     * @return uDate - java.util.Date hoac null
     */
    public static java.util.Date convertToUDate(java.sql.Timestamp timeStamp) {
        if (timeStamp == null) {
            return null;
        } else {
            java.util.Date uDate = new Date(timeStamp.getTime());
            return uDate;
        }
    }

    /**
     * <h1>convertToUDate</h1> Chuyen String dinh dang "dd/MM/yyyy" thanh ngay
     * kieu java.util.Date
     * 
     * @param dateInString
     *            String
     * @return uDate - java.util.Date hoac null
     */
    public static java.util.Date convertToUDate(String dateInString) {
        if (dateInString == null) {
            return null;
        } else {
            SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
            java.util.Date uDate = null;
            try {
                uDate = dateFormat.parse(dateInString);
            } catch (ParseException e) {
                return null;
            }
            return uDate;
        }
    }
}

Related

  1. convertToSqlDate(java.util.Date argUtilDate)
  2. convertToSQLDate(java.util.Date date)
  3. ConvertToSqlDate(java.util.Date date)
  4. convertToSqlDate(java.util.Date utilDate)
  5. convertToSqlDate(String str)
  6. createDate(int day, int month, int year)
  7. createDateFormater(int dataType)
  8. createFutureDate(java.sql.Date lmpDate, int offSet)
  9. createRecGetStatementsUpdate(String tip, String imeFirstCap)