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

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

Description

str To Date

License

Open Source License

Declaration

public static Date strToDate(String strDate, String format) 

Method Source Code

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

import java.text.ParsePosition;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Date strToDate(String strDate) {
        return strToDate(strDate, "yyyy-MM-dd");
    }/*  w  ww.java  2  s  . co m*/

    public static Date strToDate(String strDate, String format) {
        if (strDate == null) {
            return null;
        }
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        ParsePosition pos = new ParsePosition(0);
        Date strtodate = formatter.parse(strDate, pos);
        return strtodate;
    }
}

Related

  1. strToDate(String str, String format, java.util.Date defaultValue)
  2. strToDate(String strD)
  3. strToDate(String strDate)
  4. strToDate(String strDate)
  5. strToDate(String strDate)
  6. strToDate(String time, String format)
  7. strToDate3(String i_StrDate)
  8. strToDateM6(String StrToDate)
  9. StrToDateSeco(String str)