Android Date String Parse parse(String date, boolean isDateOnly)

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




public static Date parse(String date, boolean isDateOnly) 

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 {//ww  w  . j  a  va2  s. c om
            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. getDateByTime(String time)
  2. isDateString(String dirtyDate)
  3. isDateTimeString(String dirtyDateTime)
  4. parse(String date)
  5. parse(String date, String format)
  6. parse(String dateString, String dateFormat)
  7. parse(String src)
  8. parseDA(String s, boolean end)
  9. parseDT(String s, boolean end)