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
Highlighted
Developer
Posts: 95
Registered: ‎07-24-2013
My Device: 9380
My Carrier: Airtel
Accepted Solution

Blackberry java application date time format

Hi all,

 

  I am having one Date Time format like "2013-10-09T12:45:00+05:30". How can i convert it into "HH:MM a" or "hh:mm a" into my Blackberry Java Application.

 

Thanks and Best Regards.

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Blackberry java application date time format

the only dateparser is HttpDateParser, which is quite peculiar in the formats it takes. If your date adheres to the restriction you can use it, otherwise you would have to parse it yourself with substring and calendar.

 

to get the target formatting you can use SimpleDateFormat.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: Blackberry java application date time format

try this 

long millis = System.currentTimeMillis(); 
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm a");
String currentTime = sdf.format(new Date(millis));

 

Hit Like if you found this Your Solution

Developer
Posts: 95
Registered: ‎07-24-2013
My Device: 9380
My Carrier: Airtel

Re: Blackberry java application date time format

[ Edited ]

First of all Thanks for replying, Aman.

 

  from the post it seems that your  code is taking current time as input.. But friend i need to convert any time taken as input in the format like "2013-10-09T12:45:00+05:30" . I want to extract 12:45 PM from this type of input. Please help me out of it.

 

I can parse it manually..but i want to know if there is any inbuilt technique...

 

Waiting for the reply

Best Regards.

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

Re: Blackberry java application date time format

"but i want to know if there is any inbuilt technique..."

 

Simon has answered that question.

Developer
Posts: 95
Registered: ‎07-24-2013
My Device: 9380
My Carrier: Airtel

Re: Blackberry java application date time format

I could not be able to solve this using inbuilt techniques.. Anyway i parsed it manually...

 

Thankng you all for replying !!!