| 1 | #include <iostream> | 
|---|
| 2 | #include <string> | 
|---|
| 3 | #include <sstream> | 
|---|
| 4 | #include <boost/date_time.hpp> | 
|---|
| 5 |  | 
|---|
| 6 | boost::gregorian::date testDate = boost::gregorian::day_clock::local_day();//(client.dateOfBirth); | 
|---|
| 7 | boost::gregorian::date_facet *format = new boost::gregorian::date_facet("%Y-%m-%d"); | 
|---|
| 8 | std::ostringstream output1; | 
|---|
| 9 | std::wostringstream output2; | 
|---|
| 10 |  | 
|---|
| 11 | int main(int argc, char **argv){ | 
|---|
| 12 | output1.imbue(std::locale(std::locale(),format)); | 
|---|
| 13 | output1 << testDate; | 
|---|
| 14 | output2.imbue(std::locale(std::locale(),format)); | 
|---|
| 15 | output2 << testDate; | 
|---|
| 16 | std::cout << "date: " << output1.str() << std::endl; | 
|---|
| 17 | std::wcout << L"date: " << output2.str() << std::endl; | 
|---|
| 18 |  | 
|---|
| 19 | std::cout.imbue(std::locale(std::locale(),format)); | 
|---|
| 20 | std::cout << "date: "  << testDate << std::endl; | 
|---|
| 21 |  | 
|---|
| 22 | std::wcout.imbue(std::locale(std::locale(),format)); | 
|---|
| 23 | std::wcout << L"date: "  << testDate << std::endl; | 
|---|
| 24 | } | 
|---|
| 25 | /** Output: | 
|---|
| 26 | * | 
|---|
| 27 | * date: 2013-09-19 | 
|---|
| 28 | * date: 2013-Sep-19 | 
|---|
| 29 | * date: 2013-09-19 | 
|---|
| 30 | * date: 2013-Sep-19 | 
|---|
| 31 | * | 
|---|
| 32 | */ | 
|---|