aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Megert2012-02-22 15:32:43 (EST)
committerMatthias Sohn2012-02-25 17:37:02 (EST)
commit709cd52958e9794827496ce64971a65521ad02d1 (patch)
tree98e9eaa095b7f595e22c4cc11a9df0242d0805f6
parent54f23873d60f3b7f70427f5db9ff2a93229a193e (diff)
downloadjgit-709cd52958e9794827496ce64971a65521ad02d1.zip
jgit-709cd52958e9794827496ce64971a65521ad02d1.tar.gz
jgit-709cd52958e9794827496ce64971a65521ad02d1.tar.bz2
Let the date formatter pick the locale.refs/changes/66/4966/4
Instead of using the locale from the SystemReader we let the SystemReader create the date formats without passing the locale. Bug 368756 Change-Id: I6be9e07af804a08f3f3ac2d2d526ef594eed19e3 Signed-off-by: Daniel Megert <daniel_megert@ch.ibm.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java33
3 files changed, 51 insertions, 5 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
index ae1c5d9..23bf563 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
@@ -47,6 +47,8 @@ package org.eclipse.jgit.junit;
import java.io.File;
import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -151,6 +153,17 @@ public class MockSystemReader extends SystemReader {
return Locale.US;
}
+ @Override
+ public SimpleDateFormat getSimpleDateFormat(String pattern) {
+ return new SimpleDateFormat(pattern, getLocale());
+ }
+
+ @Override
+ public DateFormat getDateTimeInstance(int dateStyle, int timeStyle) {
+ return DateFormat
+ .getDateTimeInstance(dateStyle, timeStyle, getLocale());
+ }
+
/**
* Assign some properties for the currently executing platform
*/
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java
index 2f9a8dd..09326d6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, Robin Rosenberg
+ * Copyright (C) 2011, 2012 Robin Rosenberg
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -144,10 +144,10 @@ public class GitDateFormatter {
break;
case LOCALE:
case LOCALELOCAL:
- Locale locale = SystemReader.getInstance().getLocale();
- dateTimeInstance = DateFormat.getDateTimeInstance(
- DateFormat.DEFAULT, DateFormat.DEFAULT, locale);
- dateTimeInstance2 = new SimpleDateFormat("Z", locale);
+ SystemReader systemReader = SystemReader.getInstance();
+ dateTimeInstance = systemReader.getDateTimeInstance(
+ DateFormat.DEFAULT, DateFormat.DEFAULT);
+ dateTimeInstance2 = systemReader.getSimpleDateFormat("Z");
break;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
index 3afd9e5..4181a2f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
@@ -2,6 +2,7 @@
* Copyright (C) 2009, Google Inc.
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com>
+ * Copyright (C) 2012, Daniel Megert <daniel_megert@ch.ibm.com>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -48,6 +49,8 @@ package org.eclipse.jgit.util;
import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;
@@ -204,4 +207,34 @@ public abstract class SystemReader {
public Locale getLocale() {
return Locale.getDefault();
}
+
+ /**
+ * Returns a simple date format instance as specified by the given pattern.
+ *
+ * @param pattern
+ * the pattern as defined in
+ * {@link SimpleDateFormat#SimpleDateFormat(String)}
+ * @return the simple date format
+ * @since 2.0
+ */
+ public SimpleDateFormat getSimpleDateFormat(String pattern) {
+ return new SimpleDateFormat(pattern);
+ }
+
+ /**
+ * Returns a date/time format instance for the given styles.
+ *
+ * @param dateStyle
+ * the date style as specified in
+ * {@link DateFormat#getDateTimeInstance(int, int)}
+ * @param timeStyle
+ * the time style as specified in
+ * {@link DateFormat#getDateTimeInstance(int, int)}
+ * @return the date format
+ * @since 2.0
+ */
+ public DateFormat getDateTimeInstance(int dateStyle, int timeStyle) {
+ return DateFormat.getDateTimeInstance(dateStyle, timeStyle);
+ }
+
}