|
MIDP 1.0 DateField.getDate() returns null for times in the AM but not PM? -
11-15-2005, 06:56 PM
MIDP 1.0 DateField.getDate() returns null for time values in the AM but works for PM values
I have a pure midp 1.0 midlet that works well on Nokia, Sony Ericsson and Motorola devices but fails on a BB 7230.
The midlet raises a null exception when it tries to get the value in a datefield item (that is set to act as a time field) that is displaying an AM value (00:00-12:59).
- The error occurs in both 12hr and 24hr device clock settings.
- Forcing the AM/PM and Hour properties has no effect.
- It does not matter whether the time field has been edited or left with the default value.
Code snippets...
*Building the Time Field Item
...
c.set(Calendar.HOUR_OF_DAY,hour); //set time always using 24 hour time eg HOUR_OF_DAY when saving or sending
c.set(Calendar.MINUTE,minute);
c.set(Calendar.SECOND,second);
tmpItem=new DateField(label,DateField.TIME,TimeZone.getDefaul t());
((DateField)tmpItem).setDate(c.getTime());
...
*Getting the Time Field Value from a Form Item
...
}else if(p1 instanceof DateField){
//get the entered date or time
Calendar c=Calendar.getInstance();
c.setTime(((DateField)p1).getDate()); //FAILS HERE if time is AM == null returned from getDate()
...
The bb is one of the best devices out there to run my midlet - but not with the current problem.
Please help if you have seen this or any similar problems with midp on these devices.
|