Here you can find the source of toDate(String s)
Parameter | Description |
---|---|
s | a parameter |
public static Date toDate(String s)
//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; } }