Java Parse Date parseDate(String str)

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

Description

parse Date

License

Open Source License

Declaration

public static Date parseDate(String str) 

Method Source Code


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

public class Main {
    public static final String DATE_PATTERN = "yyyy-MM-dd";
    public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

    public static Date parseDate(String str) {
        return parseDateTime(str, DATE_PATTERN);
    }/* w  ww. java2s .c om*/

    public static Date parseDateTime(String str) {
        return parseDateTime(str, DATETIME_PATTERN);
    }

    public static Date parseDateTime(String str, String pattern) {
        Date d = null;
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {
            d = sdf.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return d;
    }
}

Related

  1. parseDate(String sdate, String timeFormat, String timeZone)
  2. parseDate(String sDateTime, String sPattern)
  3. parseDate(String source, String format)
  4. parseDate(String src, String pattern)
  5. parseDate(String srtDate, String pattern)
  6. parseDate(String str)
  7. parseDate(String str)
  8. parseDate(String str)
  9. parseDate(String str)