Here you can find the source of isDateString(String dirtyDate)
Parameter | Description |
---|
public static boolean isDateString(String dirtyDate)
//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; } }