Java String to Date stringToDate(String strDate, String formartStr)

Here you can find the source of stringToDate(String strDate, String formartStr)

Description

string To Date

License

Open Source License

Declaration

public static Date stringToDate(String strDate, String formartStr) 

Method Source Code


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

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

public class Main {

    public static Date stringToDate(String strDate, String formartStr) {
        Date date = null;/*www.jav a  2 s .  c  om*/
        if ((formartStr != null) && (!"".equals(formartStr))) {
            SimpleDateFormat sdf = new SimpleDateFormat(formartStr);
            try {
                date = sdf.parse(strDate);
            } catch (ParseException e) {
                date = null;
                e.printStackTrace();
            }
        }
        return date;
    }
}

Related

  1. stringToDate(String str, String formatStr)
  2. stringToDate(String strDate)
  3. stringToDate(String strDate)
  4. stringToDate(String strDate)
  5. stringToDate(String strDate)
  6. stringToDate(String strDate, String oracleFormat)
  7. stringToDate(String strDate, String pattern)
  8. stringToDate(String strDate, String strFormat)
  9. stringToDate(String string)