validating a date using dateformat [duplicate]
问题 This question already has answers here : Make SimpleDateFormat.parse() fail on invalid dates (e.g. month is greater than 12) (3 answers) Closed 11 months ago . I am trying to validate a date which is actually a string, trying to print it in yyyy/MM/dd format. Here is the code. String s="2012/12/0390990"; SimpleDateFormat ft = new SimpleDateFormat("yyyy/MM/dd"); System.out.println(ft.format(ft.parse(s))); and the output is 3083/05/30 . I want to have the validations too. No clue how to proceed