c++ - Convert a date std::string into a QuantLib::Date object -
As often happens to read such strings from .csv or .txt files, I know the easiest way to get Want to convert to a Below one example code: It is hidden, but once you Where should do the trick. % d /% m% /% y (or any other similar format) string and do something suitable for the
QuantLib :: Date object .
#include & lt; Ql / quantlib.hpp & gt; # Include & lt; Boost / timer.hpp & gt; # Include & lt; Iostream & gt; # Include & lt; Iomanip & gt; # Include & lt; Boost / algorithm / string HP & gt; Int main () {boost :: timer timer; Std :: cout & lt; & Lt; Std :: endl; Std :: string datesString = {", 17/10 / 2014/21/11 / 2014,19 / 12/2014/20/03/2015, 19/06/2015, 18/09/2015, 18 / 12/2015 , 17/06/2016, "}; Std :: vector & lt; Std :: string & gt; ExpiryDates; Promotion: Partition (end date, date string, boost: is_any_of (",")); For (int i = 0; i
& lt; Ql / utilities / dataprurs HP & gt; You can use:
date d = date parser :: parformatted (expiration date [i], format);
format is a boost.adet format string. In your case,
date d = date parser :: parformatted (expiration date [i], "% d /% m /% y");
Comments
Post a Comment