Calendar Validation

Discussion in 'Java' started by bort, Apr 12, 2004.

  1. bort

    bort Guest

    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
    bort, Apr 12, 2004
    #1
    1. Advertising

  2. bort

    Roedy Green Guest

    On Mon, 12 Apr 2004 16:35:06 GMT, "bort" <> wrote
    or quoted :

    >
    >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.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Apr 12, 2004
    #2
    1. Advertising

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

    -Mike

    "bort" <> wrote in message news:<_yzec.1552$>...
    > 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
    Michael Scovetta, Apr 13, 2004
    #3
  4. bort

    bort Guest

    Thanks Michael... worked like a charm!

    "Michael Scovetta" <> wrote in message
    news:...
    > try {
    > Calendar c = new GregorianCalendar();
    > c.setLenient(false);
    > c.set(Calendar.DATE, 44);
    > c.getTime();
    > } catch(IllegalArgumentException ex) {
    > // bad input
    > }
    >
    > -Mike
    >
    > "bort" <> wrote in message

    news:<_yzec.1552$>...
    > > 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
    bort, Apr 13, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shevek
    Replies:
    3
    Views:
    6,007
    Shevek
    Jun 23, 2004
  2. Radu
    Replies:
    0
    Views:
    384
  3. mark4asp
    Replies:
    3
    Views:
    586
    Mark Rae
    Mar 8, 2007
  4. Shevek
    Replies:
    0
    Views:
    372
    Shevek
    Jun 23, 2004
  5. Parthiv Joshi
    Replies:
    1
    Views:
    640
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page