I need to pass unique no to server every time with updated user data. For that I think, first I need to generate random no and store in a variable. When ever I need to pass updated user data, I generate random no again and compare it with stored random no. If It is different I pass it with user data otherwise I genarete it again and again until I fond different no. This sceneraio is not good for me. For generate unique no I use Calender class and get the current time in millisecond. I did not need to compare just generate the no and pass with user data.
import java.util.Calendar;
import java.util.TimeZone;
Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis();
above code return the time in milliseconds from 1970.
Using "UTC" for getting accurate value from same time zone.
Please imports related file by pressing "CTRL+SHIFT+O" keys.
No comments:
Post a Comment