Repository: thrift
Updated Branches:
  refs/heads/master dfc22ad20 -> 2a15b9937


THRIFT-3132: Java generator will properly format date in @Generated

Client: Java
Patch: Stig Bakken <[email protected]>

This closes #484


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/2a15b993
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/2a15b993
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/2a15b993

Branch: refs/heads/master
Commit: 2a15b993724dfef00bdbe28c2a7e1452dec4461a
Parents: dfc22ad
Author: Konrad Grochowski <[email protected]>
Authored: Sat May 9 11:55:36 2015 +0200
Committer: Konrad Grochowski <[email protected]>
Committed: Sat May 9 11:55:36 2015 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_java_generator.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/2a15b993/compiler/cpp/src/generate/t_java_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_java_generator.cc 
b/compiler/cpp/src/generate/t_java_generator.cc
index ee58ad5..1b1963a 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -23,6 +23,7 @@
 #include <sstream>
 #include <string>
 #include <fstream>
+#include <iomanip>
 #include <iostream>
 #include <vector>
 #include <cctype>
@@ -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;
 }
 

Reply via email to