Java Parse Date parseDate(String dateStr, SimpleDateFormat... formats)

Here you can find the source of parseDate(String dateStr, SimpleDateFormat... formats)

Description

parse Date

License

Mozilla Public License

Declaration

public static Date parseDate(String dateStr, SimpleDateFormat... formats) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0.  If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * /*from  w  w  w .j  a v a 2 s .co m*/
 * Software distributed under the License is distributed on an "AS IS" basis, 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 
 * the specific language governing rights and limitations under the License.
 *
 * The Original Code is: FetchMailAtt
 * The Initial Developer of the Original Code is: William Wong (williamw520@gmail.com)
 * Portions created by William Wong are Copyright (C) 2015 William Wong, All Rights Reserved.
 *
 ******************************************************************************/

import java.util.*;

import java.text.*;

public class Main {
    public static Date parseDate(String dateStr, SimpleDateFormat... formats) {
        for (SimpleDateFormat sdf : formats) {
            try {
                return sdf.parse(dateStr);
            } catch (ParseException ignored) {
            }
        }
        return null;
    }
}

Related

  1. parseDate(String dateStr)
  2. parseDate(String dateStr)
  3. parseDate(String dateStr)
  4. parseDate(String datestr)
  5. parseDate(String dateStr)
  6. parseDate(String dateStr, String dateFormat)
  7. parseDate(String dateStr, String dateFormat)
  8. parseDate(String dateStr, String format)
  9. parseDate(String dateStr, String format)