Hi, How can I add a single unit of time to timestamp, just like "add method" of Java "Calendar" class but by using Blackberry API set Can anyone please help me with source code?
+3
A:
You still can use Calendar in BlackBerry:
class Scr extends MainScreen {
public Scr() {
Date date = new Date(System.currentTimeMillis());
add(new LabelField("now:"));
add(new LabelField(date.toString()));
add(new LabelField("past month:"));
add(new LabelField(addDateTime(date, Calendar.MONTH, 1).toString()));
}
public Date addDateTime(Date date, int field, int addValue) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int value = c.get(field);
c.set(field, value + addValue);
return c.getTime();
}
}
Max Gontar
2010-01-18 20:52:37
Thanks Max, It worked :)
imMobile
2010-01-19 09:06:10
You welcome :)!
Max Gontar
2010-01-19 12:26:51