Validating date in java

Someone asked me what is the best way to learn a new library?In this chapter you will learn how to declare (see Section 2.1, “Declaring bean constraints”) and validate (see Section 2.2, “Validating bean constraints”) bean constraints.Usually, Simple Date Format‘s parse() method is used for validation. look at the example given below: package com.Test; import Parse Exception: Unparseable date: "2012/12/17" // at If parse() method is able to parse the date, then it is considered that input is valid. Date Format.parse(Date // at com.Test. Test Set Lenient.main(Test Set //Mon Dec 17 GMT 2012 So, clearly setting set Lenient(false); corrects the parsing behavior of Simple Date Format.It also follows good thing from Joda library about keeping human and machine interpretation of date time separated.They are also based on the ISO Calendar system and unlike their predecessor, class in class.

Seems, Java has realized a need for better date and time support, which is good for a community which already used to of Joda Date and Time API.

See Validating Persistent Fields and Properties for more information on using validation constraints.

The Java programming language distinguishes between null and empty strings.

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.

See the NOTICE file distributed with * this work for additional information regarding copyright ownership.


Leave a Reply