校验日期格式为yyyy-MM-dd

 /**
     * 校验时间
     *
     * @param text
     * @return
     */
    public static boolean checkTime(String text)
    {
        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        try
        {
            Date date = (Date)formatter.parse(text);
            return text.equals(formatter.format(date));
        }
        catch (Exception e)
        {

        }
        return false;
    }

  

posted @ 2021-06-17 16:41  云村的王子  阅读(386)  评论(0编辑  收藏  举报