簡體   English   中英

boost posix_time:字符串流輸入失敗

[英]boost posix_time: stringstream input fails

知道為什么它返回的不是日期時間而不是時間字符串嗎? 我在使用Boost 1.55.0.2的Ubuntu 15.04上

#include <iostream>
#include "boost/date_time/posix_time/posix_time.hpp"

using namespace boost::posix_time;

int main(int argc, char **argv) {

    ptime t2;
    std::stringstream ss("2004-Jan-1 05:21:33.20");
    ss >> t2;

    std::cout<<t2<< std::endl;

    return 0;
}

所需的“簡單字符串”格式為YYYY-mmm-DD HH:MM:SS.fffffffff

請參閱posix時間文檔

這一天是兩位數,因此請嘗試使用std::stringstream ss("2004-Jan-01 05:21:33.20"); 代替。

活在大腸桿菌上!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM