Java Me

Soldato
Joined
22 Nov 2007
Posts
4,360
Hi guys im a bit stuck with Java ME.
Im having trouble with retreiving a date that a user inputs into a text field.
I'll show the relevant code.

private DateField dtStartDate,dtEndDate;
private Calendar StartDate,EndDate;

StartDate= Calendar.getInstance();
StartDate.set(Calendar.YEAR ,2009);
dtStartDate = new DateField("start", DateField.DATE);
StartDate.set(Calendar.MONTH ,1);
StartDate.set(Calendar.DAY_OF_WEEK,1);
EndDate= Calendar.getInstance();
EndDate.set(Calendar.YEAR ,2009);
dtEndDate = new DateField("End Date:", DateField.DATE);
EndDate.set(Calendar.MONTH ,1);
EndDate.set(Calendar.DAY_OF_WEEK,1);

Im not sure if the above is all correct. I want to use a get method so that when the user has input the date they want for start date and end date, the date , the dates are then shown in a confirm details screen. Can any one help?
 
why dont you provide the user with 2 input fields that allow for strings, the split the strings into arrays by / then set the start and end date variables to specific indexs of the array. i.e.

string inputtedStartDate = xxx //getStartDate from user
string [] dateNumbers = inputtedStartDate.split("/");
date startDate = calendar.getInstance();
startDate.set(Calendar.day_of_week, dateNumbers[0]);
//set the rest of the date fields

something like the above.... is that what you wanted????

hope that helps
 
Back
Top Bottom