Java Parse Date parseDate(String strDate)

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

Description

parse Date

License

Apache License

Declaration

public static final Date parseDate(String strDate) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static final Date parseDate(String strDate) {
        Date date = null;/*from  ww  w . j a  v  a 2s . c o  m*/
        try {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            date = dateFormat.parse(strDate);
            return date;
        } catch (Exception pe) {
            return null;
        }
    }

    /**
      * @param strDate
      * @param pattern
      * @return
      */
    public static final Date parseDate(String strDate, String pattern) {
        SimpleDateFormat df = null;
        Date date = null;
        df = new SimpleDateFormat(pattern);
        try {
            date = df.parse(strDate);
            return date;
        } catch (Exception pe) {
            return null;
        }
    }
}

Related

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