Here you can find the source of convertToUDate(String dateInString)
Parameter | Description |
---|---|
dateInString | String |
public static java.util.Date convertToUDate(String dateInString)
//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; } } }