Android Date String Parse parse(String date, String format)

Here you can find the source of parse(String date, String format)




public static Date parse(String date, String format) 

Method Source Code

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

public class Main {
    public static Date parse(String date, String format) {
        DateFormat sdf = new SimpleDateFormat(format);
        try {//from w w w  .  j av  a2 s .c  o  m
            return sdf.parse(date);
        } catch (ParseException e) {

        return null;

    public static Date parse(String date) {
        return parse(date, "yyyy-MM-dd");

    public static Date parse(String date, boolean isDateOnly) {
        if (isDateOnly) {
            return parse(date);
        } else {
            return parse(date, "yyyy-MM-dd HH:mm");


  1. ParseStringToDate(String date)
  2. getDateByTime(String time)
  3. isDateString(String dirtyDate)
  4. isDateTimeString(String dirtyDateTime)
  5. parse(String date)
  6. parse(String date, boolean isDateOnly)
  7. parse(String dateString, String dateFormat)
  8. parse(String src)
  9. parseDA(String s, boolean end)