Java String to Date stringToDate(String string)

Here you can find the source of stringToDate(String string)

Description

return date value of specified string value in format: yyyy-MM-dd HH:mm:ss

License

Apache License

Parameter

Parameter Description
string string value to convert

Return

Date value

Declaration

public static Date stringToDate(String string) 

Method Source Code

//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;
        }
    }
}

Related

  1. stringToDate(String strDate)
  2. stringToDate(String strDate, String formartStr)
  3. stringToDate(String strDate, String oracleFormat)
  4. stringToDate(String strDate, String pattern)
  5. stringToDate(String strDate, String strFormat)
  6. stringToDate(String string, String format)
  7. stringToDate(String text)
  8. StringToDate(String thisdate, Locale locale)
  9. stringToDate(String time, String format)