You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by md...@apache.org on 2014/03/25 20:56:35 UTC

[2/3] git commit: ACCUMULO-2503 fix time zone assertion

ACCUMULO-2503 fix time zone assertion


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/55b17e47
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/55b17e47
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/55b17e47

Branch: refs/heads/master
Commit: 55b17e476686e846cdfd519393ef506e8a35a234
Parents: 1c51619
Author: Mike Drob <md...@cloudera.com>
Authored: Tue Mar 25 15:51:40 2014 -0400
Committer: Mike Drob <md...@cloudera.com>
Committed: Tue Mar 25 15:55:56 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/core/util/format/DateStringFormatter.java  | 6 ++++++
 .../accumulo/core/util/format/DateStringFormatterTest.java     | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/55b17e47/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java b/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
index 9a7febc..037ddb0 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.util.format;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Map.Entry;
+import java.util.TimeZone;
 
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
@@ -26,6 +27,7 @@ import org.apache.accumulo.core.data.Value;
 public class DateStringFormatter implements Formatter {
   private boolean printTimestamps = false;
   private DefaultFormatter defaultFormatter = new DefaultFormatter();
+
   public static final String DATE_FORMAT = "yyyy/MM/dd HH:mm:ss.SSS";
   // SimpleDataFormat is not thread safe
   private static final ThreadLocal<DateFormat> formatter = new ThreadLocal<DateFormat>() {
@@ -58,4 +60,8 @@ public class DateStringFormatter implements Formatter {
   public void remove() {
     defaultFormatter.remove();
   }
+
+  public void setTimeZone(TimeZone zone) {
+    formatter.get().setTimeZone(zone);
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/55b17e47/core/src/test/java/org/apache/accumulo/core/util/format/DateStringFormatterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/format/DateStringFormatterTest.java b/core/src/test/java/org/apache/accumulo/core/util/format/DateStringFormatterTest.java
index 69b2e11..1b121f3 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/format/DateStringFormatterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/format/DateStringFormatterTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Map;
+import java.util.TimeZone;
 import java.util.TreeMap;
 
 import org.apache.accumulo.core.data.Key;
@@ -42,9 +43,10 @@ public class DateStringFormatterTest {
   @Test
   public void testTimestamps() {
     formatter.initialize(data.entrySet(), true);
+    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
 
     assertTrue(formatter.hasNext());
-    assertTrue(formatter.next().endsWith("1969/12/31 19:00:00.000"));
+    assertTrue(formatter.next().endsWith("1970/01/01 00:00:00.000"));
   }
 
   @Test