views:

25

answers:

1
+1  Q: 

Data actualization

I created a class called DataManager and within it I called Calendar.getInstance(), this class is running on a server with exchange of sockets, but every time you change a socket, the date is never updated, it always displays the same date as the date when the class was instantiated the first time. I would have to create a thread only to keep updating the date or have another way to solve?

language: java

+1  A: 

Not sure I understand the question but it sounds like you want a sort of timestamp for when there is a change of Socket. If so, I would do something like this:

// Get calendar instance
Calendar calendar = Calendar.getInstance();

// Get a java.util.Date from the calendar instance to represent the current moment
java.util.Date newTime = calendar.getTime();
James P.
@James I think that what she wants is update the var 'calendar' asynchrony so that any incoming socket will take a "up_to_date" time. This is, if a socket come now, will take this time...if come after 3 minutes, will take the old time + 3 minutes (this is, the actual time)
Gabriel L. Oliveira