Languages

Menu
Sites
Language
Parse a date

Hello,

For my application, I need to display only the day and month of a date and I have a String date like that:

"THU, 08 AUG 2013 20:14:00 +100"

So I was wondering if there is a way to transform it into a "Tizen::Base::String" ?

I find a way to do the opposite; I mean format a date like this with this pattern "EEE, d MMM yyyy HH:mm:ss Z". But is it possible in the other way ?

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

4 Replies
Pavel Pertsev
Utility::StringTokenizer strTok(formatted, ",:+ "); String token; for (int i = 0; i < 8; i++) { if (!strTok.HasMoreTokens()) { break; } strTok.GetNextToken(token); if (i == 0) { // weekday } else if (i == 1) { // dayno } else if (i == 2) { // month } else if (i == 3) { // year } else if (i == 4) { // hour } else if (i == 5) { // minute } else if (i == 6) { // second } else if (i == 7) { // zone } }
Oberyn Martell
I just test your method and it work. Thanks, PS: If there's a method to convert directly instead of parsing manually, I'll take it
Pushpa G
Check in Tizen::Base::DateTime Class Reference available in help contents of Tizen IDE
Pavel Pertsev
I really admire the uselessness of such posts. What do you want to say? Yep, DateTime has Parse method, but it takes only specific format of the string ("mm/dd/yyyy hh:mm:ss"), while Oberyn Martell has different ("EEE, d MMM yyyy HH:mm:ss Z"), and only way he could convert something like that to DateTime is parsing string with StringTokenizer.