Java 如何使用spring引导执行器获取当前服务器时间戳

Java 如何使用spring引导执行器获取当前服务器时间戳,java,spring-boot-actuator,Java,Spring Boot Actuator,我正在使用spring boot actuator监控我的微服务的运行状况。我还需要服务器当前的时间戳。info/仅返回生成的时间戳。相反,我需要服务器当前的时间戳。请参阅 通过提供附加的InfoContributor,您可以简单地添加所需的值 @Component public class TimeInfoContributor implements InfoContributor { @Override public void contribute(Info.Builder

我正在使用spring boot actuator监控我的微服务的运行状况。我还需要服务器当前的时间戳。info/仅返回生成的时间戳。相反,我需要服务器当前的时间戳。

请参阅

通过提供附加的
InfoContributor
,您可以简单地添加所需的值

@Component
public class TimeInfoContributor implements InfoContributor {

    @Override
    public void contribute(Info.Builder builder) {
        // Calculate your desired timeValue here.
        builder.withDetail("time", timeValue);
    }

}

通过提供附加的
InfoContributor
,您可以简单地添加所需的值

@Component
public class TimeInfoContributor implements InfoContributor {

    @Override
    public void contribute(Info.Builder builder) {
        // Calculate your desired timeValue here.
        builder.withDetail("time", timeValue);
    }

}

“当前时间戳”是什么意思?服务器的系统时间?是的。我指的是服务器时间你说的“当前时间戳”是什么意思?服务器的系统时间?是的。我是说服务器时间谢谢迈克尔。我还需要记录服务器到执行器/运行状况端点的时间。在定制健康端点时,我所能找到的就是发送服务是否启动/关闭。另外我还想返回服务器时间。是否有任何方法可以实现您还可以向任何健康端点添加自定义详细信息。再见,谢谢,迈克尔。我还需要记录服务器到执行器/运行状况端点的时间。在定制健康端点时,我所能找到的就是发送服务是否启动/关闭。另外我还想返回服务器时间。是否有任何方法可以实现您还可以向任何健康端点添加自定义详细信息。看见