This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git
commit 1dd9a28fce49ff32f6f6ac6c11bd94951bab259d Author: Radu Cotescu <[email protected]> AuthorDate: Tue Jan 10 09:10:59 2017 +0000 SLING-6428 - DateFormat is printed when date-value is empty * applied patch from Vlad Băilescu git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1778098 13f79535-47bb-0310-9956-ffa450edef68 --- .../sightly/render/AbstractRuntimeObjectModel.java | 4 ++-- .../scripting/sightly/render/RuntimeObjectModel.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java b/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java index e4f84b0..357d680 100644 --- a/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java +++ b/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java @@ -104,7 +104,7 @@ public abstract class AbstractRuntimeObjectModel implements RuntimeObjectModel { if (object instanceof Number) { return (Number) object; } - return 0; + return null; } public Date toDate(Object object) { @@ -113,7 +113,7 @@ public abstract class AbstractRuntimeObjectModel implements RuntimeObjectModel { } else if (object instanceof Calendar) { return ((Calendar)object).getTime(); } - return new Date(0); + return null; } @Override diff --git a/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java b/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java index 6d8f6e0..f386634 100644 --- a/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java +++ b/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java @@ -45,8 +45,20 @@ public interface RuntimeObjectModel { */ boolean isCollection(Object target); + /** + * Checks if the provided object represents a number or not. + * + * @param target the target object + * @return {@code true} if the {@code target} is a number, {@code false} otherwise + */ boolean isNumber(Object target); + /** + * Checks if the provided object represents a date or calendar. + * + * @param target the target object + * @return {@code true} if the {@code target} is a date or calendar, {@code false} otherwise + */ boolean isDate(Object target); /** @@ -75,6 +87,12 @@ public interface RuntimeObjectModel { */ Number toNumber(Object object); + /** + * Convert the given object to a {@link Date} object + * + * @param object the target object + * @return the date represented by the {@code object} + */ Date toDate(Object object); /** -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
