Here you can find the source of parseDate(String dateString)
Parameter | Description |
---|---|
dateString | a parameter |
Parameter | Description |
---|---|
ParseException | if no format matches |
public static Date parseDate(String dateString) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String[] DATE_FORMATS = new String[] { "dd/MM/yy, HH:mm:ss", "EEE MMM d hh:mm:ss z yyyy" }; /**//from www.ja v a 2 s . c o m * Go over all date formats and try to format the given date string * @param dateString * @return * @throws ParseException if no format matches */ public static Date parseDate(String dateString) throws ParseException { ParseException exception = null; for (String format : DATE_FORMATS) { try { return new SimpleDateFormat(format).parse(dateString); } catch (ParseException e) { exception = e; } } throw exception; } }