Java String to Date getStringToDateFull(String da)

Here you can find the source of getStringToDateFull(String da)

Description

get String To Date Full

License

Apache License

Declaration

public static Date getStringToDateFull(String da) 

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 getStringToDateFull(String da) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;//from  w w w.j  a v a  2s  . c o m
        try {
            date = sdf.parse(da);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            try {
                sdf = new SimpleDateFormat("yyyy-MM-dd");
                date = sdf.parse(da);
            } catch (ParseException e2) {
                // TODO Auto-generated catch block
                e2.printStackTrace();
            }
        }
        return date;
    }
}

Related

  1. addTimeToDate(String date, int value, String unit, String sFormat)
  2. getStringToDate(String date, String format)
  3. getStringToDate(String date, String inputDateFormat)
  4. getStringToDate(String pValue, String pDateFormat)
  5. getStringToDate(String str)
  6. getStringToDateTime(String dateStr, String formatStr)
  7. getTodateString()
  8. humanDateToDate(String date)
  9. LongToDateString(long l)