gpt4 book ai didi

c++ - boost posix_time : stringstream input fails

转载 作者:行者123 更新时间:2023-11-30 05:37:58 25 4
gpt4 key购买 nike

知道为什么返回的不是日期时间,而不是时间字符串吗?我在 Ubuntu 15.04 上使用 boost 1.55.0.2

#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 time docs .

日期是两位数,所以尝试使用 std::stringstream ss("2004-Jan-01 05:21:33.20"); 代替。

Live on coliru!

关于c++ - boost posix_time : stringstream input fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33021410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com