views:

157

answers:

1

I want to be able to run an alert if the user does not change the date/calender field.

My data is set up like this

StartDate = new DateField("Start Date ", DateField.DATE);
cal1 = Calendar.getInstance();
cal1.set(Calendar.YEAR, 2009);
cal1.set(Calendar.MONTH, 0);
cal1.set(Calendar.DAY_OF_MONTH, 1);
StartDate.setDate(cal1.getTime());

And so far I have this

else if (strStartDate == "1/1/2009;") {
    AlertNameNotEntered.setString("Please enter a Start Date");
    Display.setCurrent(AlertNameNotEntered);
}

This does not work as this does not run the alert and add the date normally. I have tried a few options but they are unsuccessful.

Can anyone help by giving me the code to insert into the if statement?

Thanks

A: 

else if (StartDate.getDate().equals(cal1.getTime())) {...}

assuming you didn't change the time of cal1 between the two pieces of code in your question, of course.

java.util.Date.equals() checks for equality at the millisecond level, so you may want to check for equality of year and month and day_of_month manually if you want a 24 hours granularity instead.

QuickRecipesOnSymbianOS