Registration Screen datefield validation!
I'm writing code for RegistrationScreen (blackberry mobile app) and i am having problems with the Datefield and it's validation. This is how i get the date:
final Date currentDate = new Date();
dateField.setDate(currentDate);
dateField = new DateField ("Birthday:", 567993600, DateField.DATE | DateField.FIELD_LEFT){
public void paint(Graphics g){
g.setColor(Color.WHITE);
super.paint(g); }
};;;
(What do i have to modify, if i see that i have too, to get date in my timezone (lisbon))? (It shows the Date in the fallowing format: 14 Aug 2011)
Then the rest of the operations considering the datefield and all others, take place in开发者_如何学Cside the SubmitButton
setChangeListener
SubmitButton.setChangeListener( new FieldChangeListener() {
public void fieldChanged( Field arg0, int arg1 ) {
//I think the fallowing step saves data as a String in bDayString
String bDayString = dateField.toString();
Now, to validate the date i have to split it into tokens, which i do invoking the method splitString:
String[] formatdate = UILib.splitString(bDayString, "");
Is all this correct? If so, could you help me about this field validation? Creating a class, that i would store in Utilities Class and then call in the Registration screen. I think i have to take the Gregorian Calendar in consideration.
example of validation call (but this doesn't work for blackberry)
Check Date correctness
if (!UILib.isDateValid(bDayString))
{
Alert("Register Error", "Invalid date", false);
return;
}
Can anyone help me, please? Thank you!
Just curious why you are setting the date on the DateField and then immediately assigning it to a new DateField?
Also maybe the SimpleDateFormat class will be of some help to you? I'm not exactly sure what you're asking.
精彩评论