diff --git a/integration_test_suite/jmx_example_application/src/main/java/io/prometheus/jmx/JmxExampleApplication.java b/integration_test_suite/jmx_example_application/src/main/java/io/prometheus/jmx/JmxExampleApplication.java index d8917904..c7796cb3 100644 --- a/integration_test_suite/jmx_example_application/src/main/java/io/prometheus/jmx/JmxExampleApplication.java +++ b/integration_test_suite/jmx_example_application/src/main/java/io/prometheus/jmx/JmxExampleApplication.java @@ -17,8 +17,8 @@ package io.prometheus.jmx; import java.lang.management.ManagementFactory; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Locale; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -26,8 +26,8 @@ /** Class to implement JmxExampleApplication */ public class JmxExampleApplication { - private static final SimpleDateFormat SIMPLE_DATE_FORMAT = - new SimpleDateFormat("yyyy-MM-dd | HH:mm:ss.SSS", Locale.getDefault()); + private static final DateTimeFormatter DATE_TIME_FORMATTER = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()); /** Constructor */ private JmxExampleApplication() { @@ -61,7 +61,7 @@ public static void main(String[] args) throws Exception { System.out.printf( "%s | %s | INFO | %s | %s%n", - SIMPLE_DATE_FORMAT.format(new Date()), + LocalDateTime.now().format(DATE_TIME_FORMATTER), Thread.currentThread().getName(), JmxExampleApplication.class.getName(), "Running"); diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java index 2ebf5670..6edd2a77 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java @@ -26,15 +26,15 @@ import java.io.File; import java.lang.instrument.Instrumentation; import java.net.InetAddress; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Locale; /** Class to implement JavaAgent */ public class JavaAgent { - private static final SimpleDateFormat SIMPLE_DATE_FORMAT = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()); + private static final DateTimeFormatter DATE_TIME_FORMATTER = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()); private static final PrometheusRegistry DEFAULT_REGISTRY = PrometheusRegistry.defaultRegistry; @@ -111,7 +111,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation private static void info(String format, Object... objects) { System.out.printf( "%s | %s | INFO | %s | %s%n", - SIMPLE_DATE_FORMAT.format(new Date()), + LocalDateTime.now().format(DATE_TIME_FORMATTER), Thread.currentThread().getName(), JavaAgent.class.getName(), format(format, objects)); diff --git a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java index 3f2e0709..6d3226af 100644 --- a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java +++ b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java @@ -28,15 +28,15 @@ import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; import java.net.InetAddress; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Locale; /** Class to implement Standalone */ public class Standalone { - private static final SimpleDateFormat SIMPLE_DATE_FORMAT = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()); + private static final DateTimeFormatter DATE_TIME_FORMATTER = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()); private static final PrometheusRegistry DEFAULT_REGISTRY = PrometheusRegistry.defaultRegistry; @@ -98,7 +98,7 @@ public static void main(String[] args) throws Exception { PrometheusRegistry.defaultRegistry, file); } - info("Running ...", httpEnabled, openTelemetryEnabled); + info("Running ..."); Thread.currentThread().join(); } catch (ConfigurationException e) { @@ -143,7 +143,7 @@ private static void close(AutoCloseable autoCloseable) { private static void info(String format, Object... objects) { System.out.printf( "%s | %s | INFO | %s | %s%n", - SIMPLE_DATE_FORMAT.format(new Date()), + LocalDateTime.now().format(DATE_TIME_FORMATTER), Thread.currentThread().getName(), Standalone.class.getName(), format(format, objects));