Index: src/test/java/org/perf4j/chart/GoogleChartGeneratorTest.java
===================================================================
--- src/test/java/org/perf4j/chart/GoogleChartGeneratorTest.java (revision 73)
+++ src/test/java/org/perf4j/chart/GoogleChartGeneratorTest.java (working copy)
@@ -22,6 +22,7 @@
import java.util.ResourceBundle;
import java.util.Locale;
+import java.util.TimeZone;
/**
* Tests the GoogleChartGenerator
@@ -32,6 +33,8 @@
private ResourceBundle expectedChartUrls;
protected void setUp() throws Exception {
+ StatsValueRetriever.setTimeZone(TimeZone.getTimeZone("GMT-6"));
+
expectedChartUrls = ResourceBundle.getBundle("org/perf4j/chart/googleChartTestExpectedValues");
}
Index: src/main/java/org/perf4j/chart/GoogleChartGenerator.java
===================================================================
--- src/main/java/org/perf4j/chart/GoogleChartGenerator.java (revision 73)
+++ src/main/java/org/perf4j/chart/GoogleChartGenerator.java (working copy)
@@ -281,6 +281,7 @@
//set up the axis labels - we use the US decimal format locale to ensure the decimal separator is . and not ,
DecimalFormat decimalFormat = new DecimalFormat("##0.0", new DecimalFormatSymbols(Locale.US));
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+ dateFormat.setTimeZone(StatsValueRetriever.getTimeZone());
//the y-axis label goes from 0 to the maximum data value
String axisRangeParam = "&chxr=2,0," + decimalFormat.format(maxDataValue);
Index: src/main/java/org/perf4j/helpers/StatsValueRetriever.java
===================================================================
--- src/main/java/org/perf4j/helpers/StatsValueRetriever.java (revision 73)
+++ src/main/java/org/perf4j/helpers/StatsValueRetriever.java (working copy)
@@ -20,6 +20,7 @@
import java.util.Map;
import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.TimeZone;
/**
* The StatsValueRetriever is used to enable retrieval of any of the statistics on the TimingStatistics object
@@ -28,6 +29,7 @@
* @author Alex Devine
*/
public abstract class StatsValueRetriever {
+
public static final StatsValueRetriever MEAN_VALUE_RETRIEVER = new StatsValueRetriever() {
public Number getStatsValue(TimingStatistics timingStats, long windowLength) {
return (timingStats == null) ? 0.0 : timingStats.getMean();
@@ -106,7 +108,28 @@
DEFAULT_RETRIEVERS = Collections.unmodifiableMap(defaultRetrievers);
}
+ private static TimeZone timeZone;
+ static {
+ timeZone = TimeZone.getDefault();
+ }
+
/**
+ * Returns the TimeZone that StatisticsChartGenerators should use to format this data.
+ * @return the timezone in which the statistics should be presented
+ */
+ public static TimeZone getTimeZone() {
+ return timeZone;
+ }
+
+ /**
+ * Sets the TimeZone which should be used to present this data.
+ * @param tz the timezone to use
+ */
+ public static void setTimeZone(TimeZone tz) {
+ timeZone = tz;
+ }
+
+ /**
* Retrieves a single statistic value from the specified TimingStatistics object.
*
* @param timingStats The TimingStatistics object containing the data to be retrieved.
@@ -129,4 +152,5 @@
* @return The name of the value retrieved.
*/
public abstract String getValueName();
+
}