I don't know if this is what everyone is asking for, but basically,
credit cards are a "mod-10" format, and the expiration date
(called "expiry" in credit card parlance) cannot be > 10 years from the
current date.  Since I can't remember where I pulled this from off the
net, I'll include it here.

Hope this helps....
=======================================================================

   public boolean card_number_ok(String card_number)
          throws IOException {

      int last_digit,
          position,
          digit,
          iBeg, iEnd,
          weight = 2,
          sum = 0;
      String cLast;
      boolean bRetCode = false;      // default is NOT OK

      if (card_number.length() == 0)
                    return false;

      // compute the numerical value of the last digit
      cLast = card_number.substring(card_number.length()-1,
card_number.length());

      last_digit = Integer.parseInt(cLast);

      // go through the number starting at the 'tens' place and perform the
mod 10 weighting
      for (position=card_number.length()-2; position >= 0; position--)  {

        // weigh current digit. Note: convert ascii code to the digit it
represents
        char cc = card_number.charAt(position);
        digit = weight * (cc - '0');

        // add the digit if less than 10 to the sum, otherwise add the sum
of the digits if greater than or equal to 10
        sum = sum + (digit / 10) + (digit % 10);

        // alternately weight digits by a factors of 2 and 1
        if (weight == 2)
          weight = 1;
        else
          weight = 2;
        }   // end FOR ()

      // is the last digit the same as the computed check? */
      if (last_digit == ((10 - sum % 10) % 10))
         bRetCode= true;    // yes, valid card number

        return bRetCode;
      }

    public boolean badCardExpiryDate(int month, int year)  {
      int CC_VALID_Y_RANGE=10; // No card lasts this many years!
      Calendar newtime = Calendar.getInstance();

      java.util.Date  ltime;
      long  gmtime;
      long curr_month, curr_year;

      ltime = newtime.getTime();

      if(year < 100) {
        if(year < 70)
            year += 2000;
        else
            year += 1900;
        }
      // Convert to coordinated universal time: */
      gmtime = newtime.getTime().getTime();

      if (gmtime == 0)
        return true;  // The current time is less than Jan 1, 1970!

      curr_year = newtime.get(newtime.YEAR);// 0 means 1900 for gmtime()
      curr_month = newtime.get(newtime.MONTH) + 1;   // 0 means Jan for
gmtime()

      boolean bReturn = true;

      if((month <1 || month>12)
        || (year < curr_year)
        || (year ==  curr_year && month < curr_month)
        || (year >  (curr_year + CC_VALID_Y_RANGE))
        || (year == (curr_year + CC_VALID_Y_RANGE) && month >  curr_month))
          bReturn = false;
      return bReturn;
      }



-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Vanitha Radhakrishnan
Sent: Wednesday, December 29, 1999 11:16 AM
To: [EMAIL PROTECTED]
Subject: Re: [Re: credit card validation servlet]


Dmitry,

   Iam also working on an application which requires
the same. If possible, please do mail it to me.

Thanks,
Vanitha

--- Mahesh Patil <[EMAIL PROTECTED]> wrote:
> If possible, please send me the same.
> Mahesh
>
> sachin rameshrao zingade <[EMAIL PROTECTED]>
> wrote:
>
> > ---------------------------------------------
> >       Attachment:
> >       MIME Type: multipart/alternative
> > ---------------------------------------------
> RE: credit card validation servletif possible please
> send the same to me
>
> Sachin
>   ----- Original Message -----
>   From: Srinivas_Kondamudi
>   To: [EMAIL PROTECTED]
>   Sent: Thursday, December 09, 1999 11:12 AM
>   Subject: Re: credit card validation servlet
>
>
>   I am also working on an application that requires
> credit card validation.
>   I am also interested in the same. Please send the
> servlet code to me also.
>
>   Thanks in advance
>
>   srinivas
>
>    -----Original Message-----
>   From:   Rogatkin, Dmitry M
> [mailto:[EMAIL PROTECTED]]
>   Sent:   Thursday, December 09, 1999 5:57 AM
>   To:     [EMAIL PROTECTED]
>   Subject:        Re: credit card validation servlet
>
>   We have such part in the code of our servlet. If
> you are interested in, I
>   can send this part to you.
>
>   Dmitry.
>   ----- Original Message -----
>   From: "Sameer Tyagi" <[EMAIL PROTECTED]>
>   To: <[EMAIL PROTECTED]>
>   Sent: Wednesday, December 08, 1999 7:41 AM
>   Subject: credit card validation servlet
>
>
>
>   > Hi,
>   > Does anyone know of any Java class /servlet that
> does basic credit card
>   > number validations ?
>   >
>   > -Sam
>   >
>   >
>
>
___________________________________________________________________________
>
>   > To unsubscribe, send email to
> [EMAIL PROTECTED] and include in the
>   body
>   > of the message "signoff SERVLET-INTEREST".
>   >
>   > Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
>   > Resources:
>
http://java.sun.com/products/servlet/external-resources.html
>   > LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>   >
>
>
>
___________________________________________________________________________
>
>   To unsubscribe, send email to
> [EMAIL PROTECTED] and include in the body
>
>   of the message "signoff SERVLET-INTEREST".
>   Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
>   Resources:
>
http://java.sun.com/products/servlet/external-resources.html
>   LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>
>
>
>
____________________________________________________________________
> Get free email and a permanent address at
> http://www.netaddress.com/?N=1
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED]
> and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
>
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://messenger.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to