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

Native Development

Reply
New Developer
Posts: 75
Registered: ‎08-15-2013
My Device: blackberry curve 9630
My Carrier: Airtel

Convert QString to QDateTime

Hi All,

 

How can we convert QString to QDateTime.

 

I have  QString's as  date="1390904271356"   and readable_date="28 Jan 2014 15:47:51"

 


Please tell how to parse them and convert to QDateTime.

 

Thanks & Regards,

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Convert QString to QDateTime

[ Edited ]
QDateTime time;
time.setTime_t(1390904271356);
qDebug() << time.toString("MM dddd yyyy hh:mm:ss");

 http://qt-project.org/doc/qt-4.8/qdatetime.html#toString

 

EDIT

Hm, you want convert it to QDateTime Smiley Happy so this is for you

QDateTime time = QDateTime::fromTime_t(1390904271356);

 http://qt-project.org/doc/qt-4.8/qdatetime.html#fromTime_t



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: Convert QString to QDateTime

But because he has a string he should convert it to an integer first Smiley Happy.

 

QString str("1390904271356");

QDateTime time = QDateTime::fromTime_t(str.toInt());

 

______________________________________________________
BB10-OAuth: GitHub
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Convert QString to QDateTime

It will be probably the best Smiley Very Happy Sometimes I forget the details Smiley Wink



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog