Java Parse Date Pattern YYYY parse(String dateString)

Here you can find the source of parse(String dateString)

Description

parse

License

Open Source License

Declaration

public static java.util.Date parse(String dateString) 

Method Source Code


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

import java.util.Date;

public class Main {
    public final static String DEFAULT_FORMAT = "yyyyMMdd";

    public static java.util.Date parse(String dateString, String dateFormat) {
        if (dateString == null || "".equals(dateString.trim())) {
            return null;
        }//w  ww.ja va2 s  .  c  om
        DateFormat sdf = new SimpleDateFormat(dateFormat);
        Date date = null;
        try {
            date = sdf.parse(dateString);

        } catch (Exception e) {
            e.printStackTrace();
        }

        return date;
    }

    public static java.util.Date parse(String dateString) {
        return parse(dateString, DEFAULT_FORMAT);
    }
}

Related

  1. parse(String dateAsString)
  2. parse(String DateStr)
  3. parse(String datestr)
  4. parse(String dateStr)
  5. parse(String dateStr)
  6. parse(String dateString)
  7. parse(String dateString)
  8. parse(String dateString)
  9. parse(String dateString)