Android Date String to Date Convert toDate(String s)

Here you can find the source of toDate(String s)

Description

Parses the date string and returns the date value.

Parameter

Parameter Description
s the input string

Return

the parsed date value, null if input is null or invalid

Declaration

public static Date toDate(String s) 

Method Source Code

//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**//from   w  w  w.ja  v  a 2  s  .c  o  m
     * Parses the date string and returns the date value.
     * Input format is: <b>dd.MM.yyyy HH:mm:ss</b>.
     * 
     * @param s the input string
     * @return the parsed date value, null if input is null or invalid
     */
    public static Date toDate(String s) {
        Date date = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(
                    "dd.MM.yyyy HH:mm:ss");
            date = sdf.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}

Related

  1. changeStringToDate3(String str)
  2. convertDateStringToDate(String dateString)
  3. string2Date(String s, String s1)
  4. stringToDate(SimpleDateFormat dateFormat, String dateToConvert, boolean catchError)
  5. stringToDate(String paramString1, String paramString2, boolean paramBoolean)
  6. toDateFromString(String dateString)
  7. str2Date(String str)
  8. global2Date(String str)