brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject incubator-brooklyn git commit: fix seconds parse and add test for Time/date parsing
Date Mon, 15 Jun 2015 07:58:35 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master cfa0aa3cd -> 9c9a86670


fix seconds parse and add test for Time/date parsing


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/9c9a8667
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/9c9a8667
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/9c9a8667

Branch: refs/heads/master
Commit: 9c9a8667060c4b793345925ed2cbbe0f62d6b35f
Parents: cfa0aa3
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Jun 15 08:58:15 2015 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Jun 15 08:58:15 2015 +0100

----------------------------------------------------------------------
 utils/common/src/main/java/brooklyn/util/time/Time.java     | 4 ++--
 utils/common/src/test/java/brooklyn/util/time/TimeTest.java | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9c9a8667/utils/common/src/main/java/brooklyn/util/time/Time.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/time/Time.java b/utils/common/src/main/java/brooklyn/util/time/Time.java
index ccbb6f3..05bf088 100644
--- a/utils/common/src/main/java/brooklyn/util/time/Time.java
+++ b/utils/common/src/main/java/brooklyn/util/time/Time.java
@@ -809,8 +809,8 @@ public class Time {
                     result.set(Calendar.SECOND, Integer.parseInt(secsS));
                 } else {
                     double s = Double.parseDouble(secsS);
-                    if (s>=0 && s<=60) {
-                        // in double format, with correct period
+                    if (secsS.indexOf('.')>=0) {
+                        // accept
                     } else if (secsS.length()==5) {
                         // allow ssSSS with no punctuation
                         s = s/=1000;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9c9a8667/utils/common/src/test/java/brooklyn/util/time/TimeTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/brooklyn/util/time/TimeTest.java b/utils/common/src/test/java/brooklyn/util/time/TimeTest.java
index 5f16d5e..350b1fe 100644
--- a/utils/common/src/test/java/brooklyn/util/time/TimeTest.java
+++ b/utils/common/src/test/java/brooklyn/util/time/TimeTest.java
@@ -324,12 +324,11 @@ public class TimeTest {
         assertDatesParseToEqual("10:40:+02 2015 12 1", "2015-12-01-1040 +0200");
     }
     
-    @SuppressWarnings("deprecation")
     @Test
-    public void testParseDateToString() {
-        // java.lang.AssertionError: for: Sun Jun 07 21:21:00 BST 2015 (20150607-212100073)
expected [Sun Jun 07 21:22:13 BST 2015] but found [Sun Jun 07 21:21:00 BST 2015]
+    public void testParseDateToStringWithMillisecond() {
         Date d = new Date();
-        d.setSeconds(0);
+        // clear seconds, but add a milli - to ensure not just toString formatting but also
seconds computation
+        d.setTime(d.getTime() - (d.getTime() % 60000) + 1);
         assertDatesParseToEqual(d.toString(), Time.makeDateStampString(d.getTime()));
     }
 


Mime
View raw message