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
Posts: 61
Registered: ‎10-16-2013
My Device: Z10
My Carrier: vodaphone

QDate::fromString() fails to work

I need to extract the date from the file name.

What i m doing is :

 

QString fileName = "logs_2013_15_07.txt" ;

QDate fileDate = QDate::fromString(fileName," 'logs_'yyyy'_'MM'_'dd'.txt' ") ;
qDebug() << fileDate ;

 

following the example in the doc:

 QDateTime dateTime2 = QDateTime::fromString("M1d1y9800:01:02",
                                             "'M'M'd'd'y'yyhh:mm:ss");
 // dateTime is 1 January 1998 00:01:02

but i get invalid date.

 

is there anything i m missing??

Please help!

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: QDate::fromString() fails to work

My first guess would be the spaces between the double quote and single quote characters, but I haven't tried it. You might have more luck setting your format string to be

 

"'logs_'yyyy'_'MM'_'dd'.txt'"

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker