Android Date String Parse isDateString(String dirtyDate)

Here you can find the source of isDateString(String dirtyDate)

Description

is Date String

Parameter

Parameter Description

Return

: true - if dirtyDate is formatted as "yyyy-MM-dd"; false else

Declaration

public static boolean isDateString(String dirtyDate) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w  w . j  av a2  s .  c o m*/
     * @Title : isDateString
     * @param : dirtyDate
     * @return : true - if dirtyDate is formatted as "yyyy-MM-dd"; false else
     */
    public static boolean isDateString(String dirtyDate) {
        int len = dirtyDate.length();
        if (len == 10) {
            for (int i = 0; i < len; i++) {
                if (i == 4 || i == 7) {
                    if (dirtyDate.charAt(i) != '-')
                        return false;
                } else {
                    if (!Character.isDigit(dirtyDate.charAt(i)))
                        return false;
                }
            }
        } else {
            return false;
        }
        return true;
    }
}

Related

  1. ISO8601ToTimestamp(String aDate)
  2. ParseStringToDate(String date)
  3. getDateByTime(String time)
  4. isDateTimeString(String dirtyDateTime)
  5. parse(String date)
  6. parse(String date, String format)
  7. parse(String date, boolean isDateOnly)