Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Trusted Contributor
KJake
Posts: 156
Registered: 11-21-2010
My Carrier: Virgin Mobile

Re: HttpDateParser and SimpleDateFormat

[ Edited ]

Hi Simon.  AnswerDateTime is stored as a long.  I've tried the following code but is does not work.  Unhandles class exception.

 

Date date = (Date)settingsTable.get("AnswerDateTime");

//Long date = (Long)settingsTable.get("AnswerDateTime"); //still generates exception

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

Dialog.inform(sdf.format(date));



Any thoughts on what I am missing?  Appreciate the support.  Thanks much.

 

 

Some debugging shows that sdf.format(date) is returning --/--/----

I can see the long value is 1319847922225 but cant get it to the sdf format.

Please use plain text.
Trusted Contributor
KJake
Posts: 156
Registered: 11-21-2010
My Carrier: Virgin Mobile

Re: HttpDateParser and SimpleDateFormat

I've found that it seems to work fine if I use...

 

answerDateTime = (Long)settingsTable.get("AnswerDateTime");

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");

long thedate = Long.parseLong(answerDateTime.toString());

Dialog.inform(sdf.formatLocal(thedate));

 

Is this the ideal solution?

Please use plain text.