Here you can find the source of isValidFormat(String format, String value)
Parameter | Description |
---|---|
format | a parameter |
value | a parameter |
public static boolean isValidFormat(String format, String value)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from w w w . ja v a2 s. c o m*/ * Date string format validate * * @param format * @param value * @return */ public static boolean isValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat formatter = new SimpleDateFormat(format); formatter.setLenient(false); //make it strict date = formatter.parse(value); } catch (ParseException ex) { return false; } return date != null; } }