Java Date Parse convertDateStringToDate(String dateString, String format)

Here you can find the source of convertDateStringToDate(String dateString, String format)

Description

convert Date String To Date

License

Open Source License

Declaration

public static Date convertDateStringToDate(String dateString, String format) 

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 convertDateStringToDate(String dateString) {
        return convertDateStringToDate(dateString, "yyyy-MM-dd HH:mm:ss");
    }//from   www . j a v  a 2 s.c  o m

    public static Date convertDateStringToDate(String dateString, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date date = null;
        try {
            date = sdf.parse(dateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;

    }
}

Related

  1. asDate(String s)
  2. asDate(String string)
  3. asDate(String value, String format)
  4. convertDateForExcel(String timestamp)
  5. convertDateFromString(String data)
  6. convertDateStringToDB(String date)
  7. convertDateStringToMilliseconds(String dateString)
  8. convertIntToDate(int date)
  9. convertIntToDatePattern2(int date)