Welcome!

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

Reply
New Developer
ganeshS
Posts: 133
Registered: ‎12-31-2009

Calender Saving problem

Hello Friends

 

I am uploading my calender entries (after converting it into string , I cant avoid conversion to string) .

 

I am then downloading the calender entries from server ( I get string values).

 

I am getting date value (in string format)  as  "Fri, Apr 16, 2010 5:00PM"

 

 

then I am trying to save these downloaded calender entries programatically by using following code.

 

 

 

startDate =Long.parseLong(startTime);
			      		endDate = Long.parseLong(endTime);
				      	Dialog.alert("Values "+startDate);

						try {
							EventList eventList = (EventList) PIM
									.getInstance()
									.openPIMList(PIM.EVENT_LIST, PIM.WRITE_ONLY);
							event = eventList.createEvent();
							event.addString(Event.SUMMARY, PIMItem.ATTR_NONE,
									subject);
							event.addString(Event.LOCATION, PIMItem.ATTR_NONE,
									location);
							event.addDate(Event.END, PIMItem.ATTR_NONE,
									endDate);
							event.addDate(Event.START, PIMItem.ATTR_NONE,
									startDate);

						}
						catch (Exception e2) {
							Dialog.alert("IOException");
						}

 

 

 

 

 

 

But I am not getting long value , I am getting exception. How can I save the date which I am getting into Calender programatically?

 

 

Thank you

 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Calender Saving problem

Try parsing that date with HttpDateParser.

 

This gives you back a Date object.

 

Please use plain text.
New Developer
ganeshS
Posts: 133
Registered: ‎12-31-2009

Re: Calender Saving problem

Hello RexDoug,

 

Thank you for your reply.

 

I have already tried with "HttpDateParser", I apologize for not mentioning this in earlier post. But HttpDateParser is giving me "NumberFormatException".

 

 

Thank you

 

 

 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Calender Saving problem

Then you will have to write your own parser to extract the date elements. Since you have a single fixed date format, this shouldn't be too difficult.

 

 

Please use plain text.
New Developer
ganeshS
Posts: 133
Registered: ‎12-31-2009

Re: Calender Saving problem

Hello rexDoug,

 

Thank you for you reply.

 

 

I will write my parser and let you know what happens.

:smileytongue:

 

 

Thank you

Please use plain text.
New Developer
ganeshS
Posts: 133
Registered: ‎12-31-2009

Re: Calender Saving problem

Hello rexDoug,

 

Thank you for your sugession. It worked but the other way.

 

 

Thank you again

 

Please use plain text.