Another approach someone could take to minimise code and reduce the number of additional classes is to add a value.This isn't very portable (you can't use region specific formatting such as numerical punctuation), but this could be quite helpful for straight integers.I wanted to validate date in client side so I wrote the following code.But instead of getting an exception I am getting a proper date object for 31st of February date string, which is clearly an invalid date. Phase 1 is a basic text parse according to the fields added to the builder.
For the date question, definitely use a Simple Date Format -- rolling your own would be silly. I am currently facing a problem (a sub problem of a much larger assignment for school) where I need to validate a date.
User might enter date in format “dd/mm/yyy” or “dd-mm-yyyy” or “yy”! It runs through each format from the list and check weather input string is valid date or not.