Android Date String Parse parseDate(String str)

Here you can find the source of parseDate(String str)

Description

parse Date

Declaration

public static Date parseDate(String str) throws ParseException 

Method Source Code

//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String[] parsePatterns = new String[] {
            "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "HH:mm",
            "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd", "yyyyMMdd" };

    public static Date parseDate(String str) throws ParseException {

        return parseDate(str, parsePatterns[1]);
    }//  w w  w .  j a  v  a2 s  .  c o m

    public static Date parseDate(String str, String parsePattern)
            throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat(parsePattern);
        Date date = null;
        try {
            date = format.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;

    }
}

Related

  1. parseDate(String date, String pattern, TimeZone zone)
  2. parseDate(String dateValue)
  3. parseDate(String dateValue)
  4. parseDate(String dateValue, String[] dateFormats, Date startDate)
  5. parseDate(String dateValue, String[] dateFormats, Date startDate)
  6. parseDate(String str, String parsePattern)
  7. parseDate(String str, String... parsePatterns)
  8. parseDate(String ts)
  9. parseDate(final String dateValue, String[] dateFormats)