Java Date Parse convertStringToDate(String data)

Here you can find the source of convertStringToDate(String data)

Description

convert String To Date

License

Open Source License

Declaration

public static Date convertStringToDate(String data) 

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 convertStringToDate(String data) {
        if (data == null || data.equals(""))
            return null;

        Date date = null;/*from w ww  .  j  av a  2s. c o  m*/
        try {
            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            date = (java.util.Date) formatter.parse(data);
        } catch (ParseException e) {
            System.err.println(e.getMessage());
        }
        return date;
    }
}

Related

  1. convertIntToDatePattern2(int date)
  2. convertLongToDate(final long time)
  3. convertStringToDate(String aMask, String strDate)
  4. convertStringToDate(String aMask, String strDate)
  5. convertStringToDate(String arg)
  6. convertStringToDate(String date)
  7. convertStringToDate(String date)
  8. convertStringToDate(String date)
  9. convertStringToDate(String dateAsString)