Java String to Date StringToDate(String str, String format)

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

Description

String To Date

License

Open Source License

Declaration

public static Date StringToDate(String str, String format) throws ParseException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static Date StringToDate(String str) throws ParseException {
        return StringToDate(str, null);
    }/*from w ww  . j  a v  a 2  s .c  o m*/

    public static Date StringToDate(String str, String format) throws ParseException {
        if (str == null) {
            return null;
        }
        if (format == null) {
            format = "yyyy-MM-dd";
        }
        DateFormat df = new SimpleDateFormat(format);
        return df.parse(str);

    }
}

Related

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