Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

New Contributor
Posts: 8
Registered: ‎03-07-2013
My Device: BB10
Accepted Solution

Convert date to milliseconds



I am trying to write a function to create an event on the calendar

//the function takes in the start year, month, day and time. Also the end time


EventList eventList = (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST,PIM.WRITE_ONLY);
Event e = eventList.createEvent();
e.addString( Event.SUMMARY, PIMItem.ATTR_NONE, "The Gym");
e.addString( Event.LOCATION, PIMItem.ATTR_NONE, "Gym");

//epoch date january 1, 1970
e.addDate(Event.START, PIMItem.ATTR_NONE, startDate);
e.addDate(Event.END, PIMItem.ATTR_NONE, endDate);


I am stuck trying to figure out how to convert, say, a input 2013(year), 3(month), 7(day) into millisecond so I can

put it in startDate field



Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Convert date to milliseconds

2 options:


1) Use a Calednar Object, use the 'set' methods associated with it to set the year, month day etc (not forgetting the January is actually month 0) and then get the Date from that and then the time from the Date. 


2) Format your date so that it is acceptable to HttpDateParser, and the run that against your date string.