Java Date from String convertToDate(String date)

Here you can find the source of convertToDate(String date)

Description

convert To Date

License

Apache License

Declaration

public final static Date convertToDate(String date) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public final static Date convertToDate(String date) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");

        if (date != null && !date.isEmpty()) {
            return sdf.parse(date);
        }//from w  w w  . j  a  v  a 2s. co  m
        return null;
    }
}

Related

  1. convertToDate(final String str, final DateFormat dateFormat)
  2. convertToDate(String dateAsString)
  3. convertToDate(String dateString)
  4. convertToDate(String dateString, String format)
  5. convertToDate(String dateString, String pattern)