Calendar Validation

B

bort

Hi all

Is there a way to validate the information in a Calendar object? For
instance, if the values for April 31, 2004 were entered (at date that does
not exist), how could we determine whether it is valid or not?

tia,
bort
 
R

Roedy Green

Is there a way to validate the information in a Calendar object? For
instance, if the values for April 31, 2004 were entered (at date that does
not exist), how could we determine whether it is valid or not?

BigDate.isValid is the easiest way. See
http://mindprod.com/products.html#BIGDATE. I wrote it before
GregorianCalendar existed.

Someone else could tell you how with Calendar.
 
M

Michael Scovetta

try {
Calendar c = new GregorianCalendar();
c.setLenient(false);
c.set(Calendar.DATE, 44);
c.getTime();
} catch(IllegalArgumentException ex) {
// bad input
}

-Mike
 
B

bort

Thanks Michael... worked like a charm!

Michael Scovetta said:
try {
Calendar c = new GregorianCalendar();
c.setLenient(false);
c.set(Calendar.DATE, 44);
c.getTime();
} catch(IllegalArgumentException ex) {
// bad input
}

-Mike

"bort" <[email protected]> wrote in message
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top