Search code examples
javajavabeans

Get java Managed Bean start time


Is there a way I can obtaing the time when a bean was initialized?

I can only fin examples how to get the JVM startup time but I need to also know the difference between the JVM startup time and a bean startup time.

I can't find in the documentation anything that I can use, except for writing something to hold the start time value for a bean.

Does anyone know if there is an existing method I could use to get that?


Solution

  • Spring doesn't store it by itself.

    You can add custom code to store it. Just add method with @PostConstruct annotation to your bean and save time in it.