Here you can find the source of parseDate(String t)
static public Date parseDate(String t)
//package com.java2s; /*/*from w w w . ja v a 2 s. c o m*/ * IRIS -- Intelligent Roadway Information System * Copyright (C) 2009-2014 Minnesota Department of Transportation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. */ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** Date parser formats */ static private final DateFormat[] DATE_FORMATS = { new SimpleDateFormat("MM/dd/yy"), new SimpleDateFormat("MM/dd/yyyy"), new SimpleDateFormat("yyyy-MM-dd"), }; /** Parse a date string */ static public Date parseDate(String t) { for (DateFormat df : DATE_FORMATS) { try { return df.parse(t); } catch (ParseException e) { // Ignore } } return null; } }