Reputation: 558
Why would this:
long diffInMis = date2.getTime() - date.getTime();
diffInHour = TimeUnit.MILLISECONDS.toHours(diffInMis);
throw this:
java.lang.IllegalAccessError: tried to access method java.util.concurrent.TimeUnit.toHours:(Z)V
?
I have that error in the developer console and cannot reproduce it. By know i just do the math on my own, but I am curious.
Device: HTC Legend Android 2.2
Answer: TimeUnit missing in API < 9
Upvotes: 1
Views: 526
Reputation: 11349
Java 5 didn't have toHours, but Java 6 does. My guess is you're using a version of the TimeUnit class at runtime that doesn't include toHours. This kind of exception occurs when your code cannot access the field or method from the location of your reference.
Upvotes: 2