Java String to Date StringToDate(String str)

Here you can find the source of StringToDate(String str)

Description

String To Date

License

Apache License

Declaration

public static Date StringToDate(String str) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Date StringToDate(String str, String pattern) {
        Date dateTime = null;// w  ww.  j a  va  2 s .  c  o  m
        try {
            if (str != null && !str.equals("")) {
                SimpleDateFormat formater = new SimpleDateFormat(pattern);
                dateTime = formater.parse(str);
            }
        } catch (Exception ex) {
        }
        return dateTime;
    }

    public static Date StringToDate(String str) {
        String _pattern = "yyyy-MM-dd";
        return StringToDate(str, _pattern);
    }
}

Related

  1. stringToDate(String s, String format)
  2. stringToDate(String sDate)
  3. stringToDate(String source)
  4. stringToDate(String source, String format)
  5. stringToDate(String str)
  6. StringToDate(String str, String format)
  7. stringToDate(String str, String format)
  8. stringToDate(String str, String formatStr)
  9. stringToDate(String strDate)