Java Parse Date parseDate(String strDate)

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

Description

parse Date

License

Apache License

Parameter

Parameter Description

Return

Date

Declaration

public static Date parseDate(String strDate) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Date parseDate(String strDate, String patter) {
        Date date = null;/*from  w  ww.  j a  v a 2  s .co  m*/
        SimpleDateFormat sdf = new SimpleDateFormat(patter);
        try {
            date = sdf.parse(strDate);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
        return date;
    }

    public static Date parseDate(String strDate) {
        Date date = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            date = sdf.parse(strDate);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
        return date;
    }
}

Related

  1. parseDate(String str, Locale locale, String... parsePatterns)
  2. parseDate(String str, String pattern)
  3. parseDate(String str, String timezone)
  4. parseDate(String str, String[] parsePatterns)
  5. parseDate(String str, String[] parsePatterns)
  6. parseDate(String strDate)
  7. parseDate(String strDate)
  8. parseDate(String strDate)
  9. parseDate(String strDate, String format)