Click to See Complete Forum and Search --> : TextField Please read this I have a Problem Please Help!!


Maria4
March 2nd, 2000, 08:42 AM
I am writing an application
I created one TextField and one Button.
The user specifies a month and a year on the
Textfield,
Ex 11/1999
then clicks the show button to display the calender for the month of the year
Now my problem is once I get the String from the text field how can I differentiate between 11 and
1999.

Maria4
March 3rd, 2000, 12:40 PM
please help

kannanbalu
March 3rd, 2000, 01:20 PM
Search for the '/' delimiter in the string
and take away the tokens on both sides of it.
Use StringTokenizer class.

Kannan

poochi
March 3rd, 2000, 02:53 PM
Use StringTokenizer to parse the String


String textFieldString = textField.getText();
StringTokenizer sToken = new StringTokenizer( textFieldString , "/" );
if( sToken.countTokens() == 2 ){
String strMonth = sToken.nextToken();
String strYear = sToken.nextToken();
}else{
// Show Error Message
}