[program-java] Re: date validation

  • From: "J. R. Westmoreland" <jr@xxxxxxx>
  • To: <program-java@xxxxxxxxxxxxx>
  • Date: Fri, 23 Jan 2009 09:24:03 -0700

Right. In my case, It comes with fizz and they call it coke. Make that with
ice. <grin>
I started my job career doing COBOL programming and it nearly drove me
crazy. <smile> So, the first chance I got I changed to Fortran, better but
not the ticket yet. Then, off to assembly and then to C/C++ and about a
dozen other languages as well.
When I started Java I could have wished for Elipse or the IDEs available
now.
Anyway, remember the logic is the important part. If you can produce the
logic for the program the rest is just window-dressing.

Regards,
J. R.

--------------------
J. R. Westmoreland
E-mail: jr@xxxxxxx


-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Anna Giller
Sent: Friday, January 23, 2009 7:51 AM
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

Hi Adrian!

I'm a COBOL programmer and there is not too much in common between COBOL and
Java except for general programming logic.
I have a Master Degree in Mathematics, 15 years of programming experience,
but learning Java seems impossible for me.
It's not matter of the language itself, but the environment.
J2EE is something unlimited even conceptually.
Words like Beens, Plugins, ANT, EJB makes me frustrated.
More I learn more I need to learn.
I've started creating JSP and servlets, and nothing works. Something is
always not found.
Plus there is nobody in my office using Eclipse, so I'm on my own with all
problems.
Sorry for this whining, but your words about learning Java while drinking
coffee sound like you have a very special kind of coffee.

Anna


-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Adrian Beech
Sent: Thursday, January 22, 2009 5:08 PM
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

G'day Anna,

I've been working with Java for quite some time with all of the projects
being back end server side applications.  As for learning Java, ummmm,
that's an interesting question with the simple answer I don't recall other
than musing over some sample code one day while brewing a pot of coffee,
chuckle, .  I guess coming from a C and C++ background the transition to
Java was pretty easy given the similarities between the languages.  It also
helps that I've worked with a large number of languages over the past 30
years so it's pretty much like riding a bike -- the bikes themselves might
be different in shape, style and color but the concepts of working the thing
is still the same.

BTW, Google also helps too, hehehe!

Cheers.
AB

-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Anna Giller
Sent: Friday, 23 January 2009 6:54 AM
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

Hi Adrian!

It seems wonderful and exactly what I've been looking for.
How many years you've been working with Java, and how did you learn it?

Thank you very much,
Anna

-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Adrian Beech
Sent: Thursday, January 22, 2009 3:34 PM
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

G'day Anna,

Contenplate the code snipets below adding them in the appropriate places in
your application.

import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;

private static final String DATE_FORMAT = "dd/mm/yyyy";

SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
Date parsedDate = null;

String testString = "22/01/2009";

try
{
  parsedDate = dateFormat.parse(testString);
}
catch (ParseException e)
{
  ...
}

I would suggest that you check out the documentation for DateFormat and
SimpleDateFormat for the various tokens and there meaning.  I think it would
also be possible to get the localised date format and use this rather than
hard coding the expected pattern.  I've not had the need to do this as the
stuff I write is in house and thus for the sake of a shortcut, yudda, yudda.

Hope this is of some help.

Cheers.
AB

-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Anna Giller
Sent: Friday, 23 January 2009 6:18 AM
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

Jim:

In COBOL this routine would look about the same and as long.
I'm trying to use the advantages of Java. 
Did you ever meet the class Date Validation that J.R. was talking about?

Thanks,
Anna



-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Corbett, James
Sent: Thursday, January 22, 2009 3:13 PM
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

Anna:

Why make it complex if you don't have to.... It works, it's clean and
best of all it's free.

J. 

-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Anna Giller
Sent: January 22, 2009 14:55
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

Jim:

Thank you for this routine, but I have similar one.
I'm looking for validation using Java classes like DateFormat,
SimpleDate or any other one.

Thanks,
Anna
-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Corbett, James
Sent: Thursday, January 22, 2009 2:18 PM
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] Re: date validation

Anna:

Using date format of YYYY/MM/DD 

try{
                                int m =
Integer.valueOf(repPeriodEndDate.substring(5, 7)).intValue();
                                int d =
Integer.valueOf(repPeriodEndDate.substring(8)).intValue();

                                if(m==1 || m==3 || m==5 || m==7 || m==8
|| m==10 || m==12){
                                        if(d==31){
                                                dayValidation = true;
                                        }
                                }else if(m==4 || m==6 || m==9 || m==11){
                                        if(d==30){
                                                dayValidation = true;
                                        }

                                }else if(m==2){
                                        if(d==28 || d==29){
                                                dayValidation = true;
                                        }

                                }
                        }catch(NumberFormatException nfe){
                                nfe.printStackTrace();
                        } 

-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Anna Giller
Sent: January 22, 2009 13:39
To: program-java@xxxxxxxxxxxxx
Subject: [program-java] date validation

Jim:

 

Do you have a date validation routine?

I have one, it's ugly enough. It checks the value of the month, then the
value of the day, compares it with the array of valid values.

I need more professional one, that uses Java classes.

 

I was also looking for a numeric field validation, but just found one.

And want to share it with our people.

It's neat, isn't it?

I'm looking for a date validation routine in the similar style.

 

Thank you and the code follows.

Anna 

 

  int number=0;   

      while (number == 0) {   

    String input=JOptionPane.showInputDialog("\n\tEnter numeric
value.");   

    try{   

number=Integer.parseInt(input);   

    }catch(NumberFormatException nfe)   

    {   

Number = 0;   

    }   

 








__________ NOD32 3790 (20090122) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com






__________ NOD32 3791 (20090122) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com






Other related posts: