Java String to Date strToDate(String input, String format)

Here you can find the source of strToDate(String input, String format)

Description

str To Date

License

Apache License

Declaration

public static Date strToDate(String input, String format) 

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 strToDate(String input, String format) {
        try {/*from   w  w  w.j a  va  2 s . co  m*/
            SimpleDateFormat df = new SimpleDateFormat(format);

            return df.parse(input);
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. strToDate(String dateInString)
  2. strToDate(String dateStr, String dateFormat)
  3. strToDate(String dateStr, String format)
  4. strToDate(String format, String dateStr)
  5. strToDate(String i_StrDate, String i_Format)
  6. strToDate(String s, Date defaultValue)
  7. strToDate(String str)
  8. strToDate(String str, String format, java.util.Date defaultValue)
  9. strToDate(String strD)