Here you can find the source of parseDate(final String dateString)
Parameter | Description |
---|---|
dateString | a parameter |
public static Date parseDate(final String dateString)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*w w w . ja v a2 s . c o m*/ * This method parses a {@link Date} from a string with the format * dd.MM.yyyy kk:mm. * * @param dateString * @return */ public static Date parseDate(final String dateString) { Date date = null; DateFormat formatter; try { formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); date = formatter.parse(dateString); } catch (final ParseException d) { try { formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ"); date = formatter.parse(dateString); } catch (final ParseException e) { try { formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS"); date = formatter.parse(dateString); } catch (final ParseException f) { try { formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss"); date = formatter.parse(dateString); } catch (final ParseException g) { try { formatter = new SimpleDateFormat( "yyyy-MM-dd' 'HH:mm:ss"); date = formatter.parse(dateString); } catch (final ParseException h) { try { formatter = new SimpleDateFormat( "dd-MM-yyyy' 'HH:mm:ss"); date = formatter.parse(dateString); } catch (final ParseException i) { try { formatter = new SimpleDateFormat( "yyyy-MM-dd"); date = formatter.parse(dateString); } catch (final ParseException j) { try { formatter = new SimpleDateFormat( "dd.MM.yyyy kk:mm"); date = formatter.parse(dateString); } catch (final ParseException k) { try { // Aug 6, 2014 3:52:29 PM formatter = new SimpleDateFormat( "MMM d, yyyy h:mm:ss a"); date = formatter .parse(dateString); } catch (final ParseException l) { try { // 2013-07-14T23:30:59+02:00 formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); date = formatter .parse(dateString); } catch (final ParseException m) { // System.out.println("hpi.eap.DateUtils - date not parseable: " // + dateString); try { long longDate = Long .parseLong(dateString); date = new Date( longDate * 1000); } catch (final NumberFormatException n) { n.printStackTrace(); } } } } } } } } } } } return date; } }