Here you can find the source of parseDate(String dateValue)
Parameter | Description |
---|---|
dateValue | a parameter |
public static Date parseDate(String dateValue)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**/* www. j a va 2 s. c o m*/ * Date formats using for Date parsing. */ static final SimpleDateFormat formats[] = { new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US), new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", Locale.US), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US), new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US), new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) }; /** * Loops over all the possible date formats and tries to find the right one. * @param dateValue */ public static Date parseDate(String dateValue) { if (dateValue == null) return null; Date date = null; for (int i = 0; (date == null) && (i < formats.length); i++) { try { synchronized (formats[i]) { date = formats[i].parse(dateValue); } } catch (ParseException e) { } } return date; } }