From 2a15b993724dfef00bdbe28c2a7e1452dec4461a Mon Sep 17 00:00:00 2001 From: Konrad Grochowski Date: Sat, 9 May 2015 11:55:36 +0200 Subject: [PATCH] THRIFT-3132: Java generator will properly format date in @Generated Client: Java Patch: Stig Bakken This closes #484 --- compiler/cpp/src/generate/t_java_generator.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index ee58ad502..1b1963ab5 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,8 @@ using std::map; using std::ofstream; using std::ostringstream; +using std::setfill; +using std::setw; using std::string; using std::stringstream; using std::vector; @@ -5090,7 +5093,9 @@ void t_java_generator::generate_javax_generated_annotation(ofstream& out) { time_t seconds = time(NULL); struct tm* now = localtime(&seconds); indent(out) << "@Generated(value = \"" << autogen_summary() << "\", date = \"" - << (now->tm_year + 1900) << "-" << (now->tm_mon + 1) << "-" << now->tm_mday << "\")" + << (now->tm_year + 1900) + << "-" << setfill('0') << setw(2) << (now->tm_mon + 1) + << "-" << setfill('0') << setw(2) << now->tm_mday << "\")" << endl; }