Android Date String to Date Convert parse2Date(SimpleDateFormat s, Object d)

Here you can find the source of parse2Date(SimpleDateFormat s, Object d)

Description

parse Date

Declaration

public static Date parse2Date(SimpleDateFormat s, Object d) 

Method Source Code

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

public class Main {
    public static Date parse2Date(SimpleDateFormat s, Object d) {
        if (d instanceof String) {
            try {
                return s.parse(d.toString());
            } catch (ParseException e) {
                return new Date();
            }//  w w w  .  jav a 2 s  . c om
        } else if (d instanceof Date) {
            return (Date) d;
        } else {
            return new Date();
        }
    }
}

Related

  1. parseTaskWarrior(String date)
  2. getDate(String sDate, String dateFormat)
  3. convertStringToDate(String dateString, String currentFormat)
  4. dateToString(Date date, String format)
  5. parseStringToDate(String dateString, String sourceDateFormat, Locale locale)
  6. stringToDate(String src, String format)
  7. toDateFromLongFormat(String date)
  8. parse(String aFormat, String date)
  9. getDate(String date)