I've pinned down a performance and crash problem on the N95 to this sequence of code. I need the date and time in this exact format: "YYYY-MM-DD HH:MM:SS", and what follows is the way I solved it. Please indicate if I'm doing something fundamentally wrong in achieving what I intend. Even so, it shouldn't bog down the CPU.
pTimeBase controls whether time info should be taken from the phone or a pre-set time value (from GPS). As the issues occur also when the date variable is used, it's not "new Date()" that's the problem, but rather the Calendar related methods. This occurs on no other phone I've tested with, including 6630 that's also Series 60 but much older.
Date actualDate = (pTimeBase == TBPHONE || !active) ? new Date() : date;
Calendar cal = Calendar.getInstance();
"20" + valStr(cal.get(Calendar.YEAR)) + datedel +
valStr(cal.get(Calendar.MONTH) - Calendar.JANUARY + 1) + datedel +
valStr(cal.get(Calendar.DAY_OF_MONTH)) + " " +
valStr(cal.get(Calendar.HOUR_OF_DAY)) + timedel +
valStr(cal.get(Calendar.MINUTE)) + timedel +
private String valStr(int val)
if (val <= 0 || val >= 100)
else if (val < 10)
return "0" + Integer.toString(val);
Thanks in advance