Android Date String to Date Convert string2Date(String s, String s1)

Here you can find the source of string2Date(String s, String s1)

Description

string Date

Declaration

public static Date string2Date(String s, String s1) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static Date string2Date(String s, String s1) {
        Date date = new Date();
        try {//w  ww . j  av a  2  s. co  m
            String s2 = stringNull(s1);
            SimpleDateFormat simpledateformat = new SimpleDateFormat(s2);
            String s3 = stringNull(s);
            date = simpledateformat.parse(s3);
        } catch (Exception exception) {
        }
        return date;
    }

    public static String stringNull(String s) {
        if (s != null) {
            s = s.trim();
            if (s.equals("") || s.equalsIgnoreCase("null"))
                s = "";
        }
        return s;
    }
}

Related

  1. changeStringToDate(String fecha, String pattern)
  2. changeStringToDate1(String str)
  3. changeStringToDate2(String str)
  4. changeStringToDate3(String str)
  5. convertDateStringToDate(String dateString)
  6. stringToDate(SimpleDateFormat dateFormat, String dateToConvert, boolean catchError)
  7. stringToDate(String paramString1, String paramString2, boolean paramBoolean)
  8. toDate(String s)
  9. toDateFromString(String dateString)