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
Developer
Curahee
Posts: 229
Registered: ‎01-12-2013
My Device: z30
Accepted Solution

QDateTim::fromString() does not work

What is the problem with the next piece of code?

 

QDateTime pub = QDateTime::fromString("20 Mar 2013", "dd MMM yyyy");

 I just don't get it...

______________________________________________________
BB10-OAuth: GitHub
Developer
Curahee
Posts: 229
Registered: ‎01-12-2013
My Device: z30

Re: QDateTim::fromString() does not work

It looks like that function is dependent on the language setting of the device. I support 4 different languages, but the timestring I get from the datasource is always the same. So how can I convert my date decently in all the languages?

 

QDateTime::fromString("Wed, 20 Mar 2013 17:17:00", "ddd, dd MMM yyyy hh:mm:ss");

 This works if my locale is set to english. But when I set it to dutch, it will not work. How to solve this annoying problem?

______________________________________________________
BB10-OAuth: GitHub
Developer
Curahee
Posts: 229
Registered: ‎01-12-2013
My Device: z30

Re: QDateTim::fromString() does not work

I found a solution for this one.

 

QLocale loc(QLocale::English);

QDateTime dateTime = loc.toDateTime("Wed, 20 Mar 2013 17:17:00", "ddd, dd MMM yyyy hh:mm:ss");

 This way, the date will always be interpreted as an english date offcourse.

______________________________________________________
BB10-OAuth: GitHub