Java String to Date toDate(String s)

Here you can find the source of toDate(String s)

Description

returns the date that correspond to the given text DD-MM-YYYY

License

Open Source License

Parameter

Parameter Description
s a parameter

Declaration

public static Date toDate(String s) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * This file is part of ISPyB.// w w w.  j a  v a2  s  . co  m
 * 
 * ISPyB is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ISPyB is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ISPyB.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors : S. Delageniere, R. Leal, L. Launer, K. Levik, S. Veyrier, P. Brenchereau, M. Bodin, A. De Maria Antolinos
 ******************************************************************************/

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**
     * returns the date that correspond to the given text DD-MM-YYYY
     * 
     * @param s
     * @return
     */
    public static Date toDate(String s) {
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        df.setLenient(false);
        Date d = null;
        try {
            d = df.parse(s);
        } catch (Exception e) {

        }
        return d;
    }
}

Related

  1. toDate(String formatDate, String stringDate)
  2. toDate(String param)
  3. toDate(String patten, String value)
  4. toDate(String pattern, String date)
  5. toDate(String pString, String pFormat)
  6. toDate(String s)
  7. toDate(String s, String format)
  8. toDate(String sdate, SimpleDateFormat dateFormater)
  9. toDate(String sDate, String sFmt)