camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r898656 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/language/simple/SimpleLanguage.java test/java/org/apache/camel/language/SimpleTest.java
Date Wed, 13 Jan 2010 06:15:48 GMT
Author: davsclaus
Date: Wed Jan 13 06:15:48 2010
New Revision: 898656

URL: http://svn.apache.org/viewvc?rev=898656&view=rev
Log:
CAMEL-2353: Fixed simple language and using complex date patterns

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java?rev=898656&r1=898655&r2=898656&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
Wed Jan 13 06:15:48 2010
@@ -137,11 +137,11 @@
         remainder = ifStartsWithReturnRemainder("date:", expression);
         if (remainder != null) {
             String[] parts = remainder.split(":");
-            if (parts.length != 2) {
+            if (parts.length < 2) {
                 throw new ExpressionIllegalSyntaxException("Valid syntax: ${date:command:pattern}
was: " + expression);
             }
-            String command = parts[0];
-            String pattern = parts[1];
+            String command = ObjectHelper.before(remainder, ":");
+            String pattern = ObjectHelper.after(remainder, ":");
             return ExpressionBuilder.dateExpression(command, pattern);
         }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java?rev=898656&r1=898655&r2=898656&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java Wed Jan
13 06:15:48 2010
@@ -74,6 +74,15 @@
         }
     }
 
+    public void testDateAndTimeExpressions() throws Exception {
+        Calendar cal = GregorianCalendar.getInstance();
+        cal.set(1974, Calendar.APRIL, 20, 8,55, 47);
+        cal.set(Calendar.MILLISECOND, 123);
+        exchange.getIn().setHeader("birthday", cal.getTime());
+
+        assertExpression("date:header.birthday:yyyy-MM-dd'T'HH:mm:ss:SSS", "1974-04-20T08:55:47:123");
+    }
+
     public void testLanguagesInContext() throws Exception {
         // evaluate so we know there is 1 language in the context
         assertExpression("id", exchange.getIn().getMessageId());



Mime
View raw message