From a001c513612d4ff6434da778a5e35cb041e5c6cc Mon Sep 17 00:00:00 2001 From: Henner Dream Machine Date: Thu, 11 Mar 2021 22:27:15 +0100 Subject: [PATCH 1/2] added two methods to be more Java Convention like --- .../org/apache/cayenne/gen/StringUtils.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java index c2f86153f0..e20ca5ab53 100644 --- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java +++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java @@ -158,6 +158,31 @@ else if (str.endsWith("y")) { } } + /** + * Converts string to camel case string + * @param aString + * @param upOrDown + * @return camel cased version + */ + public String camelCase(String aString, boolean upOrDown) { + if (aString == null || aString.length() == 0) { + return aString; + } + return Util.underscoredToJava(aString, upOrDown); + } + + /** + * Converts string to lower case + * @param aString + * @return + */ + public String toLowerCase(String aString) { + if (aString == null || aString.length() == 0) { + return aString; + } + return aString.toLowerCase(); + } + /** *

* Strip generic definition from string From 048d398b4791f0a83dfa5e479f155a5205a5a67b Mon Sep 17 00:00:00 2001 From: Henner Date: Fri, 26 Nov 2021 19:03:53 +0100 Subject: [PATCH 2/2] added possibility to add date and time --- .../java/org/apache/cayenne/gen/StringUtils.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java index e20ca5ab53..9d83b72f3d 100644 --- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java +++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java @@ -22,6 +22,9 @@ import org.apache.cayenne.project.validation.NameValidationHelper; import org.apache.cayenne.util.Util; +import java.text.SimpleDateFormat; +import java.util.Calendar; + /** * Methods for mangling strings. */ @@ -183,6 +186,16 @@ public String toLowerCase(String aString) { return aString.toLowerCase(); } + + public String dateAndTimeNow() { + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd--HH:mm"); + Calendar calendar = Calendar.getInstance(); + return formatter.format( calendar.getTime()); + + + } + /** *

* Strip generic definition from string