Here you can find the source of strToDate(String strD)
Parameter | Description |
---|---|
strD | the string date format:yyyy-MM-dd HH:mm:ss |
public static Date strToDate(String strD)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**//from w w w .j a v a 2s.co m * Convert string to date object * * @param strD * the string date format:yyyy-MM-dd HH:mm:ss * @return */ public static Date strToDate(String strD) { try { String strFormat = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(strFormat); return sdf.parse(strD); } catch (java.text.ParseException e) { return new Date(); } } }