Java Parse Date parseDate(String currDate)

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

Description

parse Date

License

Apache License

Declaration

public static Date parseDate(String currDate) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static Date parseDate(String currDate, String format) {
        SimpleDateFormat dtFormatdB = null;
        try {//  w w w .j  av a2s  .  c o m
            dtFormatdB = new SimpleDateFormat(format);
            return dtFormatdB.parse(currDate);
        } catch (Exception e) {
            dtFormatdB = new SimpleDateFormat("yyyy-MM-dd");
            try {
                return dtFormatdB.parse(currDate);
            } catch (Exception ex) {
            }
        }
        return null;
    }

    public static Date parseDate(String currDate) {
        SimpleDateFormat dtFormatdB = null;
        dtFormatdB = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return dtFormatdB.parse(currDate);
        } catch (Exception e) {
            try {
                return dtFormatdB.parse(currDate);
            } catch (Exception ex) {
            }
        }
        return null;
    }
}

Related

  1. parseDate(String _dateString)
  2. parseDate(String actual, DateFormat format, Pattern pattern)
  3. parseDate(String applyDt)
  4. parseDate(String buildDate, SimpleDateFormat dateFormat)
  5. parseDate(String certDate)
  6. parseDate(String d)
  7. parseDate(String d)
  8. parseDate(String d)
  9. parseDate(String datastr, String pattern)