I know that there are many os posts on how to get the current time in java. But I am planning on getAge Method code in the Persona class. The problem is that I need to get the current time every time the method is called. Let them say that a billion clients are executed by getMethod (with milliseconds, perhaps seconds of difference), a billion objects will be created for such a simple thing. The only thing I did was create a static element in Person, so Person will share the instance. But this does not prevent the creation of the object.
public class Person{
If you know some library that is implemented without loss of this heap size. Tell me please.
Thanks.
user1096311
source share