I have an ArrayList that includes several timestamps, and the goal is to find the difference between the first and last ArrayList elements.
String a = ArrayList.get(0); String b = ArrayList.get(ArrayList.size()-1); long diff = b.getTime() - a.getTime();
I also converted the types to int, but still it gives me the error The method getTime is undefined for the type String .
Additional Information:
I have a class A that includes
String timeStamp = new SimpleDateFormat("ss S").format(new Date());
and there is a class B that has a private void dialogDuration(String timeStamp) method
and dialogueDuration includes:
String a = timeSt.get(0);
And one condition is that the operator ( String timeStamp = new SimpleDateFormat("ss S").format(new Date()); ) will not be changed in class A. And the object of class B is created in class A, so that it calls method dialogueDuration(timeStamp) and passes the values โโof timestamps to class B.
My problem is that this subtraction does not work, it gives the error cannot invoke getTime() method on the primitive type long . Does it give the same error also for int and String types?
Thank you very much!
source share