Here you can find the source of stringToDate(String string)
Parameter | Description |
---|---|
string | string value to convert |
public static Date stringToDate(String string)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from w w w. j a v a 2 s . com*/ * return date value of specified string value in format: yyyy-MM-dd HH:mm:ss * * @param string string value to convert * @return Date value */ public static Date stringToDate(String string) { try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return simpleDateFormat.parse(string); } catch (Exception e) { return null; } } }